add support of Optional Mappin Configuration Support in MapConvert Extensions Methods ...
This commit is contained in:
@@ -304,10 +304,14 @@ namespace xCommons.Extensions
|
|||||||
/// Convert Using Auto Mapper ...
|
/// Convert Using Auto Mapper ...
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="source"></param>
|
/// <param name="source"></param>
|
||||||
|
/// <param name="cfgAction"></param>
|
||||||
/// <typeparam name="T"></typeparam>
|
/// <typeparam name="T"></typeparam>
|
||||||
/// <typeparam name="E"></typeparam>
|
/// <typeparam name="E"></typeparam>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static T MapConvert<T, E>(this E source)
|
public static T MapConvert<T, E>(
|
||||||
|
this E source,
|
||||||
|
Action<IMapperConfigurationExpression> cfgAction = null
|
||||||
|
)
|
||||||
where T : class
|
where T : class
|
||||||
where E : class
|
where E : class
|
||||||
{
|
{
|
||||||
@@ -320,8 +324,16 @@ namespace xCommons.Extensions
|
|||||||
//
|
//
|
||||||
var dMapConfig = new MapperConfiguration(b =>
|
var dMapConfig = new MapperConfiguration(b =>
|
||||||
{
|
{
|
||||||
|
//
|
||||||
b.CreateMap<T, E>()
|
b.CreateMap<T, E>()
|
||||||
.ReverseMap();
|
.ReverseMap();
|
||||||
|
|
||||||
|
//
|
||||||
|
// Use Specified Provided Actions if Exists ...
|
||||||
|
if (!cfgAction.IsNull())
|
||||||
|
{
|
||||||
|
cfgAction.Invoke(b);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
var dMapper = dMapConfig.CreateMapper();
|
var dMapper = dMapConfig.CreateMapper();
|
||||||
|
|
||||||
@@ -337,10 +349,14 @@ namespace xCommons.Extensions
|
|||||||
/// Convert Using Auto Mapper ...
|
/// Convert Using Auto Mapper ...
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="source"></param>
|
/// <param name="source"></param>
|
||||||
|
/// <param name="cfgAction"></param>
|
||||||
/// <typeparam name="T"></typeparam>
|
/// <typeparam name="T"></typeparam>
|
||||||
/// <typeparam name="E"></typeparam>
|
/// <typeparam name="E"></typeparam>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static IEnumerable<T> MapConvert<T, E>(this IEnumerable<E> source)
|
public static IEnumerable<T> MapConvert<T, E>(
|
||||||
|
this IEnumerable<E> source,
|
||||||
|
Action<IMapperConfigurationExpression> cfgAction = null
|
||||||
|
)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
if (source.IsNull())
|
if (source.IsNull())
|
||||||
@@ -351,8 +367,16 @@ namespace xCommons.Extensions
|
|||||||
//
|
//
|
||||||
var dMapConfig = new MapperConfiguration(b =>
|
var dMapConfig = new MapperConfiguration(b =>
|
||||||
{
|
{
|
||||||
|
//
|
||||||
b.CreateMap<T, E>()
|
b.CreateMap<T, E>()
|
||||||
.ReverseMap();
|
.ReverseMap();
|
||||||
|
|
||||||
|
//
|
||||||
|
// Use Specified Provided Actions if Exists ...
|
||||||
|
if (!cfgAction.IsNull())
|
||||||
|
{
|
||||||
|
cfgAction.Invoke(b);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
var dMapper = dMapConfig.CreateMapper();
|
var dMapper = dMapConfig.CreateMapper();
|
||||||
|
|
||||||
@@ -368,10 +392,14 @@ namespace xCommons.Extensions
|
|||||||
/// Convert Using Auto Mapper ...
|
/// Convert Using Auto Mapper ...
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="source"></param>
|
/// <param name="source"></param>
|
||||||
|
/// <param name="cfgAction"></param>
|
||||||
/// <typeparam name="T"></typeparam>
|
/// <typeparam name="T"></typeparam>
|
||||||
/// <typeparam name="E"></typeparam>
|
/// <typeparam name="E"></typeparam>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static ICollection<T> MapConvert<T, E>(this ICollection<E> source)
|
public static ICollection<T> MapConvert<T, E>(
|
||||||
|
this ICollection<E> source,
|
||||||
|
Action<IMapperConfigurationExpression> cfgAction = null
|
||||||
|
)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
if (source.IsNull())
|
if (source.IsNull())
|
||||||
@@ -382,8 +410,16 @@ namespace xCommons.Extensions
|
|||||||
//
|
//
|
||||||
var dMapConfig = new MapperConfiguration(b =>
|
var dMapConfig = new MapperConfiguration(b =>
|
||||||
{
|
{
|
||||||
|
//
|
||||||
b.CreateMap<T, E>()
|
b.CreateMap<T, E>()
|
||||||
.ReverseMap();
|
.ReverseMap();
|
||||||
|
|
||||||
|
//
|
||||||
|
// Use Specified Provided Actions if Exists ...
|
||||||
|
if (!cfgAction.IsNull())
|
||||||
|
{
|
||||||
|
cfgAction.Invoke(b);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
var dMapper = dMapConfig.CreateMapper();
|
var dMapper = dMapConfig.CreateMapper();
|
||||||
|
|
||||||
@@ -399,10 +435,14 @@ namespace xCommons.Extensions
|
|||||||
/// Convert Using Auto Mapper ...
|
/// Convert Using Auto Mapper ...
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="source"></param>
|
/// <param name="source"></param>
|
||||||
|
/// <param name="cfgAction"></param>
|
||||||
/// <typeparam name="T"></typeparam>
|
/// <typeparam name="T"></typeparam>
|
||||||
/// <typeparam name="E"></typeparam>
|
/// <typeparam name="E"></typeparam>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static IList<T> MapConvert<T, E>(this IList<E> source)
|
public static IList<T> MapConvert<T, E>(
|
||||||
|
this IList<E> source,
|
||||||
|
Action<IMapperConfigurationExpression> cfgAction = null
|
||||||
|
)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
if (source.IsNull())
|
if (source.IsNull())
|
||||||
@@ -413,8 +453,16 @@ namespace xCommons.Extensions
|
|||||||
//
|
//
|
||||||
var dMapConfig = new MapperConfiguration(b =>
|
var dMapConfig = new MapperConfiguration(b =>
|
||||||
{
|
{
|
||||||
|
//
|
||||||
b.CreateMap<T, E>()
|
b.CreateMap<T, E>()
|
||||||
.ReverseMap();
|
.ReverseMap();
|
||||||
|
|
||||||
|
//
|
||||||
|
// Use Specified Provided Actions if Exists ...
|
||||||
|
if (!cfgAction.IsNull())
|
||||||
|
{
|
||||||
|
cfgAction.Invoke(b);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
var dMapper = dMapConfig.CreateMapper();
|
var dMapper = dMapConfig.CreateMapper();
|
||||||
|
|
||||||
@@ -430,11 +478,15 @@ namespace xCommons.Extensions
|
|||||||
/// Convert Using Auto Mapper ...
|
/// Convert Using Auto Mapper ...
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="source"></param>
|
/// <param name="source"></param>
|
||||||
|
/// <param name="cfgAction"></param>
|
||||||
/// <typeparam name="TKey"></typeparam>
|
/// <typeparam name="TKey"></typeparam>
|
||||||
/// <typeparam name="TDest"></typeparam>
|
/// <typeparam name="TDest"></typeparam>
|
||||||
/// <typeparam name="TSource"></typeparam>
|
/// <typeparam name="TSource"></typeparam>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static IDictionary<TKey, TDest> MapConvert<TKey, TDest, TSource>(this IDictionary<TKey, TSource> source)
|
public static IDictionary<TKey, TDest> MapConvert<TKey, TDest, TSource>(
|
||||||
|
this IDictionary<TKey, TSource> source,
|
||||||
|
Action<IMapperConfigurationExpression> cfgAction = null
|
||||||
|
)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
if (source.IsNull())
|
if (source.IsNull())
|
||||||
@@ -445,8 +497,16 @@ namespace xCommons.Extensions
|
|||||||
//
|
//
|
||||||
var dMapConfig = new MapperConfiguration(b =>
|
var dMapConfig = new MapperConfiguration(b =>
|
||||||
{
|
{
|
||||||
|
//
|
||||||
b.CreateMap<TDest, TSource>()
|
b.CreateMap<TDest, TSource>()
|
||||||
.ReverseMap();
|
.ReverseMap();
|
||||||
|
|
||||||
|
//
|
||||||
|
// Use Specified Provided Actions if Exists ...
|
||||||
|
if (!cfgAction.IsNull())
|
||||||
|
{
|
||||||
|
cfgAction.Invoke(b);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
var dMapper = dMapConfig.CreateMapper();
|
var dMapper = dMapConfig.CreateMapper();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user