-
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.
Added basic implementations using AutoMapper and Mapster
- Loading branch information
Showing
9 changed files
with
182 additions
and
18 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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation"> | ||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Mapster/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary> |
36 changes: 18 additions & 18 deletions
36
src/YuckQi.Extensions.Mapping.Abstractions/YuckQi.Extensions.Mapping.Abstractions.csproj
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,23 +1,23 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>netstandard2.0</TargetFramework> | ||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild> | ||
<Authors>Kevin J Lambert</Authors> | ||
<Version>1.0.0</Version> | ||
<Description>Mapping abstractions for an object-to-object mapper.</Description> | ||
<RepositoryUrl>https://github.com/Yuck/YuckQi.Extensions.Mapping.Abstractions.git</RepositoryUrl> | ||
<RepositoryType>git</RepositoryType> | ||
<PackageLicenseExpression>MIT</PackageLicenseExpression> | ||
<PackageProjectUrl>https://github.com/Yuck/YuckQi.Extensions.Mapping.Abstractions</PackageProjectUrl> | ||
<PackageReadmeFile>readme.md</PackageReadmeFile> | ||
</PropertyGroup> | ||
<PropertyGroup> | ||
<TargetFramework>netstandard2.0</TargetFramework> | ||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild> | ||
<Authors>Kevin J Lambert</Authors> | ||
<Version>1.0.0</Version> | ||
<Description>Mapping abstractions for an object-to-object mapper.</Description> | ||
<RepositoryUrl>https://github.com/Yuck/YuckQi.Extensions.Mapping.Abstractions.git</RepositoryUrl> | ||
<RepositoryType>git</RepositoryType> | ||
<PackageLicenseExpression>MIT</PackageLicenseExpression> | ||
<PackageProjectUrl>https://github.com/Yuck/YuckQi.Extensions.Mapping.Abstractions</PackageProjectUrl> | ||
<PackageReadmeFile>readme.md</PackageReadmeFile> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<None Update="readme.md"> | ||
<Pack>True</Pack> | ||
<PackagePath>\</PackagePath> | ||
</None> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Update="readme.md"> | ||
<Pack>True</Pack> | ||
<PackagePath>\</PackagePath> | ||
</None> | ||
</ItemGroup> | ||
|
||
</Project> |
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 |
---|---|---|
@@ -0,0 +1,44 @@ | ||
using System; | ||
using AutoMapper; | ||
using AutoMapperIMapper = AutoMapper.IMapper; | ||
using IMapper = YuckQi.Extensions.Mapping.Abstractions.IMapper; | ||
|
||
namespace YuckQi.Extensions.Mapping.AutoMapper | ||
{ | ||
public class DefaultMapper : IMapper | ||
{ | ||
#region Private Members | ||
|
||
private readonly AutoMapperIMapper _mapper; | ||
|
||
#endregion | ||
|
||
|
||
#region Constructors | ||
|
||
public DefaultMapper(IConfigurationProvider configuration) | ||
{ | ||
if (configuration == null) | ||
throw new ArgumentNullException(nameof(configuration)); | ||
|
||
_mapper = configuration.CreateMapper(); | ||
} | ||
|
||
#endregion | ||
|
||
|
||
#region Public Methods | ||
|
||
public Object Map(Object source, Object destination, Type sourceType, Type destinationType) => _mapper.Map(source, destination, sourceType, destinationType); | ||
|
||
public Object Map(Object source, Type sourceType, Type destinationType) => _mapper.Map(source, sourceType, destinationType); | ||
|
||
public TDestination Map<TDestination>(Object source) => _mapper.Map<TDestination>(source); | ||
|
||
public TDestination Map<TSource, TDestination>(TSource source) => _mapper.Map<TSource, TDestination>(source); | ||
|
||
public TDestination Map<TSource, TDestination>(TSource source, TDestination destination) => _mapper.Map(source, destination); | ||
|
||
#endregion | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
src/YuckQi.Extensions.Mapping.AutoMapper/YuckQi.Extensions.Mapping.AutoMapper.csproj
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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>netstandard2.0</TargetFramework> | ||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild> | ||
<Authors>Kevin J Lambert</Authors> | ||
<Version>1.0.0</Version> | ||
<Description>A basic mapper implementation using the AutoMapper framework.</Description> | ||
<RepositoryUrl>https://github.com/Yuck/YuckQi.Extensions.Mapping.Abstractions.git</RepositoryUrl> | ||
<RepositoryType>git</RepositoryType> | ||
<PackageLicenseExpression>MIT</PackageLicenseExpression> | ||
<PackageProjectUrl>https://github.com/Yuck/YuckQi.Extensions.Mapping.Abstractions</PackageProjectUrl> | ||
<PackageReadmeFile>readme.md</PackageReadmeFile> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="AutoMapper" Version="10.1.1" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\YuckQi.Extensions.Mapping.Abstractions\YuckQi.Extensions.Mapping.Abstractions.csproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<None Update="readme.md"> | ||
<Pack>True</Pack> | ||
<PackagePath>\</PackagePath> | ||
</None> | ||
</ItemGroup> | ||
|
||
</Project> |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
# YuckQi.Extensions.Mapping.Abstractions |
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 |
---|---|---|
@@ -0,0 +1,42 @@ | ||
using System; | ||
using Mapster; | ||
using MapsterMapper; | ||
using IMapper = YuckQi.Extensions.Mapping.Abstractions.IMapper; | ||
using MapsterIMapper = MapsterMapper.IMapper; | ||
|
||
namespace YuckQi.Extensions.Mapping.Mapster | ||
{ | ||
public class DefaultMapper : IMapper | ||
{ | ||
#region Private Members | ||
|
||
private readonly MapsterIMapper _mapper; | ||
|
||
#endregion | ||
|
||
|
||
#region Constructors | ||
|
||
public DefaultMapper(TypeAdapterConfig configuration = null) | ||
{ | ||
_mapper = configuration != null ? new Mapper(configuration) : new Mapper(); | ||
} | ||
|
||
#endregion | ||
|
||
|
||
#region Public Methods | ||
|
||
public Object Map(Object source, Object destination, Type sourceType, Type destinationType) => _mapper.Map(source, destination, sourceType, destinationType); | ||
|
||
public Object Map(Object source, Type sourceType, Type destinationType) => _mapper.Map(source, sourceType, destinationType); | ||
|
||
public TDestination Map<TDestination>(Object source) => _mapper.Map<TDestination>(source); | ||
|
||
public TDestination Map<TSource, TDestination>(TSource source) => _mapper.Map<TSource, TDestination>(source); | ||
|
||
public TDestination Map<TSource, TDestination>(TSource source, TDestination destination) => _mapper.Map(source, destination); | ||
|
||
#endregion | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
src/YuckQi.Extensions.Mapping.Mapster/YuckQi.Extensions.Mapping.Mapster.csproj
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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>netstandard2.0</TargetFramework> | ||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild> | ||
<Authors>Kevin J Lambert</Authors> | ||
<Version>1.0.0</Version> | ||
<Description>A basic mapper implementation using the Mapster framework.</Description> | ||
<RepositoryUrl>https://github.com/Yuck/YuckQi.Extensions.Mapping.Abstractions.git</RepositoryUrl> | ||
<RepositoryType>git</RepositoryType> | ||
<PackageLicenseExpression>MIT</PackageLicenseExpression> | ||
<PackageProjectUrl>https://github.com/Yuck/YuckQi.Extensions.Mapping.Abstractions</PackageProjectUrl> | ||
<PackageReadmeFile>readme.md</PackageReadmeFile> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Mapster" Version="7.2.0" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\YuckQi.Extensions.Mapping.Abstractions\YuckQi.Extensions.Mapping.Abstractions.csproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<None Update="readme.md"> | ||
<Pack>True</Pack> | ||
<PackagePath>\</PackagePath> | ||
</None> | ||
</ItemGroup> | ||
|
||
</Project> |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
# YuckQi.Extensions.Mapping.Abstractions |