Skip to content

Commit

Permalink
Merge pull request #124 from fluentsprings/feature/inheritance-support
Browse files Browse the repository at this point in the history
Feature/inheritance support
  • Loading branch information
anisimovyuriy authored Jan 18, 2017
2 parents c684dd8 + 78550a8 commit 609d936
Show file tree
Hide file tree
Showing 91 changed files with 4,840 additions and 2,242 deletions.
8 changes: 8 additions & 0 deletions .idea/.idea.ExpressMapper/.idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/.idea.ExpressMapper/.idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1,858 changes: 1,858 additions & 0 deletions .idea/.idea.ExpressMapper/.idea/workspace.xml

Large diffs are not rendered by default.

47 changes: 47 additions & 0 deletions .idea/.idea.ExpressMapper/riderModule.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 3 additions & 39 deletions ExpressMapper NET40/ExpressMapper NET40.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
<SignAssembly>true</SignAssembly>
</PropertyGroup>
<PropertyGroup>
<AssemblyOriginatorKeyFile>Expressmapper.snk</AssemblyOriginatorKeyFile>
<AssemblyOriginatorKeyFile>
</AssemblyOriginatorKeyFile>
</PropertyGroup>
<PropertyGroup>
<DelaySign>false</DelaySign>
Expand All @@ -51,49 +52,12 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="CollectionTypes.cs" />
<Compile Include="CompilationTypes.cs" />
<Compile Include="Constants.cs" />
<Compile Include="DefaultMappingContext.cs" />
<Compile Include="DelegateCustomTypeMapper.cs" />
<Compile Include="DestinationTypeMapper.cs" />
<Compile Include="ExpressmapperException.cs" />
<Compile Include="ExpressmapperExtensions.cs" />
<Compile Include="FlattenMemberInfo.cs" />
<Compile Include="FlattenMapper.cs" />
<Compile Include="IMappingContext.cs" />
<Compile Include="IMappingServiceProvider.cs" />
<Compile Include="FlattenLinqMethod.cs" />
<Compile Include="MapNotImplemented.cs" />
<Compile Include="MappingServiceProvider.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="NullCheckNestedMemberVisitor.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="DestinationMappingService.cs" />
<Compile Include="IMappingService.cs" />
<Compile Include="MappingServiceBase.cs" />
<Compile Include="PreciseSubstituteParameterVisitor.cs" />
<Compile Include="ProjectionAccessMemberVisitor.cs" />
<Compile Include="ReturnTypeDifferenceVisitor.cs" />
<Compile Include="SourceMappingService.cs" />
<Compile Include="SourceTypeMapper.cs" />
<Compile Include="StaticExpressions.cs" />
<Compile Include="SubstituteParameterVisitor.cs" />
<Compile Include="ITypeMapper.cs" />
<Compile Include="ICustomTypeMapper.cs" />
<Compile Include="IMemberConfiguration.cs" />
<Compile Include="Mapper.cs" />
<Compile Include="MemberConfiguration.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="TypeExtensions.cs" />
<Compile Include="TypeMapperBase.cs" />
</ItemGroup>
<ItemGroup>
<None Include="Expressmapper.snk" />
</ItemGroup>
<ItemGroup />
<Import Project="..\Expressmapper.Shared\Expressmapper.Shared.projitems" Label="Shared" />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
Expand Down
6 changes: 3 additions & 3 deletions ExpressMapper NET40/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.8.3.0")]
[assembly: AssemblyFileVersion("1.8.3.0")]
[assembly: AssemblyInformationalVersion("1.8.3")]
[assembly: AssemblyVersion("1.9.0.0")]
[assembly: AssemblyFileVersion("1.9.0.0")]
[assembly: AssemblyInformationalVersion("1.9.0")]
97 changes: 1 addition & 96 deletions ExpressMapper NET45/ExpressMapper NET45.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -47,109 +47,14 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\ExpressMapper NET40\CollectionTypes.cs">
<Link>CollectionTypes.cs</Link>
</Compile>
<Compile Include="..\ExpressMapper NET40\CompilationTypes.cs">
<Link>CompilationTypes.cs</Link>
</Compile>
<Compile Include="..\ExpressMapper NET40\DefaultMappingContext.cs">
<Link>DefaultMappingContext.cs</Link>
</Compile>
<Compile Include="..\ExpressMapper NET40\DelegateCustomTypeMapper.cs">
<Link>DelegateCustomTypeMapper.cs</Link>
</Compile>
<Compile Include="..\ExpressMapper NET40\DestinationMappingService.cs">
<Link>DestinationMappingService.cs</Link>
</Compile>
<Compile Include="..\ExpressMapper NET40\DestinationTypeMapper.cs">
<Link>DestinationTypeMapper.cs</Link>
</Compile>
<Compile Include="..\ExpressMapper NET40\ExpressmapperException.cs">
<Link>ExpressmapperException.cs</Link>
</Compile>
<Compile Include="..\ExpressMapper NET40\ExpressmapperExtensions.cs">
<Link>ExpressmapperExtensions.cs</Link>
</Compile>
<Compile Include="..\ExpressMapper NET40\FlattenLinqMethod.cs">
<Link>FlattenLinqMethod.cs</Link>
</Compile>
<Compile Include="..\ExpressMapper NET40\FlattenMapper.cs">
<Link>FlattenMapper.cs</Link>
</Compile>
<Compile Include="..\ExpressMapper NET40\FlattenMemberInfo.cs">
<Link>FlattenMemberInfo.cs</Link>
</Compile>
<Compile Include="..\ExpressMapper NET40\ICustomTypeMapper.cs">
<Link>ICustomTypeMapper.cs</Link>
</Compile>
<Compile Include="..\ExpressMapper NET40\IMappingContext.cs">
<Link>IMappingContext.cs</Link>
</Compile>
<Compile Include="..\ExpressMapper NET40\IMappingService.cs">
<Link>IMappingService.cs</Link>
</Compile>
<Compile Include="..\ExpressMapper NET40\IMappingServiceProvider.cs">
<Link>IMappingServiceProvider.cs</Link>
</Compile>
<Compile Include="..\ExpressMapper NET40\IMemberConfiguration.cs">
<Link>IMemberConfiguration.cs</Link>
</Compile>
<Compile Include="..\ExpressMapper NET40\ITypeMapper.cs">
<Link>ITypeMapper.cs</Link>
</Compile>
<Compile Include="..\ExpressMapper NET40\MapNotImplemented.cs">
<Link>MapNotImplemented.cs</Link>
</Compile>
<Compile Include="..\ExpressMapper NET40\Mapper.cs">
<Link>Mapper.cs</Link>
</Compile>
<Compile Include="..\ExpressMapper NET40\MappingServiceBase.cs">
<Link>MappingServiceBase.cs</Link>
</Compile>
<Compile Include="..\ExpressMapper NET40\MappingServiceProvider.cs">
<Link>MappingServiceProvider.cs</Link>
</Compile>
<Compile Include="..\ExpressMapper NET40\MemberConfiguration.cs">
<Link>MemberConfiguration.cs</Link>
</Compile>
<Compile Include="..\ExpressMapper NET40\NullCheckNestedMemberVisitor.cs">
<Link>NullCheckNestedMemberVisitor.cs</Link>
</Compile>
<Compile Include="..\ExpressMapper NET40\PreciseSubstituteParameterVisitor.cs">
<Link>PreciseSubstituteParameterVisitor.cs</Link>
</Compile>
<Compile Include="..\ExpressMapper NET40\ProjectionAccessMemberVisitor.cs">
<Link>ProjectionAccessMemberVisitor.cs</Link>
</Compile>
<Compile Include="..\ExpressMapper NET40\Properties\AssemblyInfo.cs">
<Link>Properties\AssemblyInfo.cs</Link>
</Compile>
<Compile Include="..\ExpressMapper NET40\ReturnTypeDifferenceVisitor.cs">
<Link>ReturnTypeDifferenceVisitor.cs</Link>
</Compile>
<Compile Include="..\ExpressMapper NET40\SourceMappingService.cs">
<Link>SourceMappingService.cs</Link>
</Compile>
<Compile Include="..\ExpressMapper NET40\SourceTypeMapper.cs">
<Link>SourceTypeMapper.cs</Link>
</Compile>
<Compile Include="..\ExpressMapper NET40\StaticExpressions.cs">
<Link>StaticExpressions.cs</Link>
</Compile>
<Compile Include="..\ExpressMapper NET40\SubstituteParameterVisitor.cs">
<Link>SubstituteParameterVisitor.cs</Link>
</Compile>
<Compile Include="..\ExpressMapper NET40\TypeExtensions.cs">
<Link>TypeExtensions.cs</Link>
</Compile>
<Compile Include="..\ExpressMapper NET40\TypeMapperBase.cs">
<Link>TypeMapperBase.cs</Link>
</Compile>
</ItemGroup>
<ItemGroup>
<None Include="Expressmapper.snk" />
</ItemGroup>
<Import Project="..\Expressmapper.Shared\Expressmapper.Shared.projitems" Label="Shared" />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
Expand Down
10 changes: 5 additions & 5 deletions ExpressMapper NETCORE/DestinationMappingService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ public override BlockExpression MapProperty(Type srcType, Type destType, Express
var blockForSubstitution = Expression.Block(mapExprForType);
var substBlock =
new PreciseSubstituteParameterVisitor(
new KeyValuePair<ParameterExpression, ParameterExpression>(mapExpressions.Item2, sourceVariable),
new KeyValuePair<ParameterExpression, ParameterExpression>(mapExpressions.Item3, destVariable))
.Visit(blockForSubstitution) as
new KeyValuePair<ParameterExpression, ParameterExpression>(mapExpressions.Item2, sourceVariable),
new KeyValuePair<ParameterExpression, ParameterExpression>(mapExpressions.Item3, destVariable))
.Visit(blockForSubstitution) as
BlockExpression;

//var substBlock =
Expand Down Expand Up @@ -183,7 +183,7 @@ private BlockExpression MapCollectionNotCountEquals(Type tCol, Type tnCol, Expre

BlockExpression resultExpression;
var isICollection = !destVariable.Type.IsArray && (destVariable.Type.GetInfo().GetInterfaces()
.FirstOrDefault(t => t.GetInfo().IsGenericType && t.GetGenericTypeDefinition() == typeof(ICollection<>)) != null ||
.FirstOrDefault(t => t.GetInfo().IsGenericType && t.GetGenericTypeDefinition() == typeof(ICollection<>)) != null ||
destVariable.Type == destCollection);

var srcCount = Expression.Call(typeof(Enumerable), "Count", new[] { sourceType }, sourceVariable);
Expand Down Expand Up @@ -245,7 +245,7 @@ private BlockExpression MapCollectionNotCountEquals(Type tCol, Type tnCol, Expre
var closedEnumeratorDestType = typeof(IEnumerator<>).MakeGenericType(destType);
var closedEnumerableDestType = GenericEnumerableType.MakeGenericType(destType);
var enumeratorDest = Expression.Variable(closedEnumeratorDestType,
$"{Guid.NewGuid().ToString("N")}EnumDst");
$"{Guid.NewGuid():N}EnumDst");
var assignToEnumDest = Expression.Assign(enumeratorDest,
Expression.Call(destVariable, closedEnumerableDestType.GetInfo().GetMethod("GetEnumerator")));
var doMoveNextDest = Expression.Call(enumeratorDest, typeof(IEnumerator).GetInfo().GetMethod("MoveNext"));
Expand Down
2 changes: 1 addition & 1 deletion ExpressMapper NETCORE/DestinationTypeMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class DestinationTypeMapper<T, TN> : TypeMapperBase<T, TN>, ITypeMapper<T

#endregion

public DestinationTypeMapper(IMappingService service, IMappingServiceProvider serviceProvider) : base(service, serviceProvider){}
public DestinationTypeMapper(IMappingService service, IMappingServiceProvider serviceProvider) : base(service, serviceProvider) { }

public override CompilationTypes MapperType => CompilationTypes.Destination;

Expand Down
2 changes: 2 additions & 0 deletions ExpressMapper NETCORE/IMappingServiceProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@ public interface IMappingServiceProvider
object Map(Type srcType, Type dstType, object src);
object Map(Type srcType, Type dstType, object src, object dest);
IMemberConfiguration<T, TN> Register<T, TN>();
IMemberConfiguration<T, TN> Register<T, TN>(IMemberConfigParameters baseType);
bool MapExists(Type sourceType, Type destinationType);
void RegisterCustom<T, TN, TMapper>() where TMapper : ICustomTypeMapper<T, TN>;
void RegisterCustom<T, TN>(Func<T, TN> mapFunc);
void Reset();
long CalculateCacheKey(Type src, Type dest);
Dictionary<long, Func<ICustomTypeMapper>> CustomMappers { get; }
Dictionary<int, IList<long>> CustomMappingsBySource { get; }
IQueryable<TN> Project<T, TN>(IQueryable<T> source);
bool CaseSensetiveMemberMap { get; set; }
}
Expand Down
18 changes: 18 additions & 0 deletions ExpressMapper NETCORE/IMemberConfigParameters.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using System.Collections.Generic;
using System.Linq.Expressions;

namespace ExpressMapper
{
public interface IMemberConfigParameters
{
List<KeyValuePair<MemberExpression, Expression>> CustomMembers { get; }
List<KeyValuePair<MemberExpression, Expression>> FlattenMembers { get; }
List<KeyValuePair<MemberExpression, Expression>> CustomFunctionMembers { get; }
List<string> IgnoreMemberList { get; }
bool Flattened { get; set; }
bool CaseSensetiveMember { get; set; }
bool CaseSensetiveOverride { get; set; }
CompilationTypes CompilationTypeMember { get; set; }
bool CompilationTypeOverride { get; set; }
}
}
3 changes: 3 additions & 0 deletions ExpressMapper NETCORE/IMemberConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,8 @@ public interface IMemberConfiguration<T, TN>
IMemberConfiguration<T, TN> CaseSensitive(bool caseSensitive);
IMemberConfiguration<T, TN> CompileTo(CompilationTypes compilationType);
IMemberConfiguration<T, TN> Flatten();

IMemberConfiguration<T, TN> Include<TSub, TNSub>() where TSub : T
where TNSub : TN;
}
}
5 changes: 5 additions & 0 deletions ExpressMapper NETCORE/ITypeMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ namespace ExpressMapper
{
public interface ITypeMapper
{
bool BaseType { get; set; }
Type SourceType { get; }
Type DestinationType { get; }
Expression QueryableGeneralExpression { get; }
Func<object, object, object> GetNonGenericMapFunc();
Tuple<List<Expression>, ParameterExpression, ParameterExpression> GetMapExpressions();
Expand All @@ -20,6 +23,7 @@ public interface ITypeMapper
/// <typeparam name="TN">destination</typeparam>
public interface ITypeMapper<T, TN> : ITypeMapper
{
IMemberConfiguration<T, TN> MemberConfiguration { get; set; }
Expression<Func<T, TN>> QueryableExpression { get; }
TN MapTo(T src, TN dest);
void Ignore<TMember>(Expression<Func<TN, TMember>> left);
Expand All @@ -35,5 +39,6 @@ public interface ITypeMapper<T, TN> : ITypeMapper
void AfterMap(Action<T,TN> afterMap);
void Flatten();
CompilationTypes MapperType { get; }
void ImportMemberConfigParameters(IMemberConfigParameters baseClassConfiguration);
}
}
Loading

0 comments on commit 609d936

Please sign in to comment.