-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from NerosoftDev/develop
Develop
- Loading branch information
Showing
64 changed files
with
811 additions
and
150 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -365,3 +365,4 @@ Resource.designer.cs | |
.DS_Store | ||
nupkg/ | ||
.fleet/ | ||
.vscode/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
147 changes: 72 additions & 75 deletions
147
Source/Euonia.Mapping.Automapper/AutomapperTypeAdapter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,86 +1,83 @@ | ||
using AutoMapper; | ||
using Microsoft.Extensions.DependencyInjection; | ||
|
||
namespace Nerosoft.Euonia.Mapping; | ||
|
||
public class AutomapperTypeAdapter : ITypeAdapter | ||
{ | ||
private readonly IServiceProvider _provider; | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
/// <param name="provider"></param> | ||
public AutomapperTypeAdapter(IServiceProvider provider) | ||
{ | ||
_provider = provider; | ||
} | ||
{ | ||
private readonly IMapper _mapper; | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
/// <param name="source"></param> | ||
/// <typeparam name="TSource"></typeparam> | ||
/// <typeparam name="TDestination"></typeparam> | ||
/// <returns></returns> | ||
public TDestination Adapt<TSource, TDestination>(TSource source) | ||
where TSource : class | ||
where TDestination : class | ||
{ | ||
return GetMapper().Map<TSource, TDestination>(source); | ||
} | ||
/// <summary> | ||
/// | ||
/// </summary> | ||
/// <param name="mapper"></param> | ||
public AutomapperTypeAdapter(IMapper mapper) | ||
{ | ||
_mapper = mapper; | ||
} | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
/// <param name="source"></param> | ||
/// <param name="destination"></param> | ||
/// <typeparam name="TSource"></typeparam> | ||
/// <typeparam name="TDestination"></typeparam> | ||
/// <returns></returns> | ||
public TDestination Adapt<TSource, TDestination>(TSource source, TDestination destination) | ||
where TSource : class | ||
where TDestination : class | ||
{ | ||
return GetMapper().Map(source, destination); | ||
} | ||
/// <summary> | ||
/// | ||
/// </summary> | ||
/// <param name="source"></param> | ||
/// <typeparam name="TSource"></typeparam> | ||
/// <typeparam name="TDestination"></typeparam> | ||
/// <returns></returns> | ||
public TDestination Adapt<TSource, TDestination>(TSource source) | ||
where TSource : class | ||
where TDestination : class | ||
{ | ||
return _mapper.Map<TSource, TDestination>(source); | ||
} | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
/// <param name="source"></param> | ||
/// <typeparam name="TDestination"></typeparam> | ||
/// <returns></returns> | ||
public TDestination Adapt<TDestination>(object source) | ||
where TDestination : class | ||
{ | ||
return GetMapper().Map<TDestination>(source); | ||
} | ||
/// <summary> | ||
/// | ||
/// </summary> | ||
/// <param name="source"></param> | ||
/// <param name="destination"></param> | ||
/// <typeparam name="TSource"></typeparam> | ||
/// <typeparam name="TDestination"></typeparam> | ||
/// <returns></returns> | ||
public TDestination Adapt<TSource, TDestination>(TSource source, TDestination destination) | ||
where TSource : class | ||
where TDestination : class | ||
{ | ||
return _mapper.Map(source, destination); | ||
} | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
/// <param name="source"></param> | ||
/// <param name="destinationType"></param> | ||
/// <returns></returns> | ||
public object Adapt(object source, Type destinationType) | ||
{ | ||
var sourceType = source.GetType(); | ||
return GetMapper().Map(source, sourceType, destinationType); | ||
} | ||
/// <summary> | ||
/// | ||
/// </summary> | ||
/// <param name="source"></param> | ||
/// <typeparam name="TDestination"></typeparam> | ||
/// <returns></returns> | ||
public TDestination Adapt<TDestination>(object source) | ||
where TDestination : class | ||
{ | ||
return _mapper.Map<TDestination>(source); | ||
} | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
/// <param name="source"></param> | ||
/// <param name="destination"></param> | ||
/// <typeparam name="TDestination"></typeparam> | ||
/// <returns></returns> | ||
public TDestination Adapt<TDestination>(object source, TDestination destination) | ||
where TDestination : class | ||
{ | ||
return GetMapper().Map(source, destination); | ||
} | ||
/// <summary> | ||
/// | ||
/// </summary> | ||
/// <param name="source"></param> | ||
/// <param name="destinationType"></param> | ||
/// <returns></returns> | ||
public object Adapt(object source, Type destinationType) | ||
{ | ||
var sourceType = source.GetType(); | ||
return _mapper.Map(source, sourceType, destinationType); | ||
} | ||
|
||
private IMapper GetMapper() => _provider.GetRequiredService<IMapper>(); | ||
} | ||
/// <summary> | ||
/// | ||
/// </summary> | ||
/// <param name="source"></param> | ||
/// <param name="destination"></param> | ||
/// <typeparam name="TDestination"></typeparam> | ||
/// <returns></returns> | ||
public TDestination Adapt<TDestination>(object source, TDestination destination) | ||
where TDestination : class | ||
{ | ||
return _mapper.Map(source, destination); | ||
} | ||
} |
12 changes: 7 additions & 5 deletions
12
Source/Euonia.Mapping.Automapper/AutomapperTypeAdapterFactory.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,18 @@ | ||
namespace Nerosoft.Euonia.Mapping; | ||
using AutoMapper; | ||
|
||
namespace Nerosoft.Euonia.Mapping; | ||
|
||
public class AutomapperTypeAdapterFactory : ITypeAdapterFactory | ||
{ | ||
private readonly IServiceProvider _serviceProvider; | ||
private readonly IMapper _mapper; | ||
|
||
public AutomapperTypeAdapterFactory(IServiceProvider serviceProvider) | ||
public AutomapperTypeAdapterFactory(IMapper mapper) | ||
{ | ||
_serviceProvider = serviceProvider; | ||
_mapper = mapper; | ||
} | ||
|
||
public ITypeAdapter Create() | ||
{ | ||
return new AutomapperTypeAdapter(_serviceProvider); | ||
return new AutomapperTypeAdapter(_mapper); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 11 additions & 2 deletions
13
Source/Euonia.Mapping.Mapster/MapsterTypeAdapterFactory.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,18 @@ | ||
namespace Nerosoft.Euonia.Mapping; | ||
using MapsterMapper; | ||
|
||
namespace Nerosoft.Euonia.Mapping; | ||
|
||
public class MapsterTypeAdapterFactory : ITypeAdapterFactory | ||
{ | ||
private readonly IMapper _mapper; | ||
|
||
public MapsterTypeAdapterFactory(IMapper mapper) | ||
{ | ||
_mapper = mapper; | ||
} | ||
|
||
public ITypeAdapter Create() | ||
{ | ||
throw new NotImplementedException(); | ||
return new MapsterTypeAdapter(_mapper); | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.