Skip to content

Commit

Permalink
Net core support
Browse files Browse the repository at this point in the history
  • Loading branch information
yanisimov committed Sep 6, 2016
1 parent f484e0e commit 64d65b0
Show file tree
Hide file tree
Showing 176 changed files with 24,977 additions and 389 deletions.
163 changes: 79 additions & 84 deletions ExpressMapper NET40/DestinationMappingService.cs

Large diffs are not rendered by default.

9 changes: 3 additions & 6 deletions ExpressMapper NET40/DestinationTypeMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;

namespace ExpressMapper
{
Expand All @@ -14,16 +13,14 @@ 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 {
get { return CompilationTypes.Destination;}
}
public override CompilationTypes MapperType => CompilationTypes.Destination;

protected override void InitializeRecursiveMappings(IMappingServiceProvider serviceProvider)
{
var mapMethod =
typeof(IMappingServiceProvider).GetMethods()
typeof(IMappingServiceProvider).GetInfo().GetMethods()
.First(mi => mi.Name == MapStr && mi.GetParameters().Length == 2)
.MakeGenericMethod(typeof(T), typeof(TN));

Expand Down
3 changes: 1 addition & 2 deletions ExpressMapper NET40/ExpressMapper NET40.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@
<Compile Include="FlattenMapper.cs" />
<Compile Include="IMappingContext.cs" />
<Compile Include="IMappingServiceProvider.cs" />
<Compile Include="Ioc\DependencyResolver.cs" />
<Compile Include="Ioc\IContainer.cs" />
<Compile Include="FlattenLinqMethod.cs" />
<Compile Include="MapNotImplemented.cs" />
<Compile Include="MappingServiceProvider.cs">
Expand All @@ -89,6 +87,7 @@
<Compile Include="Mapper.cs" />
<Compile Include="MemberConfiguration.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="TypeExtensions.cs" />
<Compile Include="TypeMapperBase.cs" />
</ItemGroup>
<ItemGroup>
Expand Down
14 changes: 7 additions & 7 deletions ExpressMapper NET40/FlattenLinqMethod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ internal class FlattenLinqMethod

static FlattenLinqMethod()
{
EnumerableMethodLookup =
EnumerableMethodLookup =
(from givenName in ListOfSupportedLinqMethods
let checkReturnType = givenName[0] != '~'
let name = checkReturnType ? givenName : givenName.Substring(1)
select new FlattenLinqMethod(name, checkReturnType) ).ToList();
let checkReturnType = givenName[0] != '~'
let name = checkReturnType ? givenName : givenName.Substring(1)
select new FlattenLinqMethod(name, checkReturnType)).ToList();
}

/// <summary>
Expand All @@ -35,7 +35,7 @@ static FlattenLinqMethod()
/// <summary>
/// If true then the return type should be checked to get the right version of the method
/// </summary>
private readonly bool _checkReturnType ;
private readonly bool _checkReturnType;

private FlattenLinqMethod(string methodName, bool checkReturnType)
{
Expand All @@ -61,9 +61,9 @@ public override string ToString()

public MethodCallExpression AsMethodCallExpression(Expression propertyExpression, PropertyInfo propertyToActOn, PropertyInfo destProperty)
{
var ienumerableType = propertyToActOn.PropertyType.GetGenericArguments().Single();
var ienumerableType = propertyToActOn.PropertyType.GetInfo().GetGenericArguments().Single();

var foundMethodInfo = typeof (Enumerable).GetMethods()
var foundMethodInfo = typeof(Enumerable).GetInfo().GetMethods()
.SingleOrDefault(m => m.Name == _methodName && m.GetParameters().Length == 1
&& (!_checkReturnType || m.ReturnType == destProperty.PropertyType));

Expand Down
22 changes: 11 additions & 11 deletions ExpressMapper NET40/FlattenMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,21 +42,21 @@ public List<FlattenMemberInfo> BuildMemberMapping()
return _foundFlattens;
}

private void ScanSourceProps(List<PropertyInfo> sourcePropsToScan,
private void ScanSourceProps(List<PropertyInfo> sourcePropsToScan,
string prefix = "", PropertyInfo[] sourcePropPath = null)
{
foreach (var destProp in _filteredDestProps.ToList())
//scan source property name against dest that has no direct match with any of the source property names
if (_filteredDestProps.Contains(destProp))
//This allows for entries to be removed from the list
ScanSourceClassRecursively(sourcePropsToScan, destProp, prefix, sourcePropPath ?? new PropertyInfo [] {});
ScanSourceClassRecursively(sourcePropsToScan, destProp, prefix, sourcePropPath ?? new PropertyInfo[] { });
}

private void ScanSourceClassRecursively(IEnumerable<PropertyInfo> sourceProps, PropertyInfo destProp,
string prefix, PropertyInfo [] sourcePropPath)
private void ScanSourceClassRecursively(IEnumerable<PropertyInfo> sourceProps, PropertyInfo destProp,
string prefix, PropertyInfo[] sourcePropPath)
{

foreach (var matchedStartSrcProp in sourceProps.Where(x => destProp.Name.StartsWith(prefix+x.Name, _stringComparison)))
foreach (var matchedStartSrcProp in sourceProps.Where(x => destProp.Name.StartsWith(prefix + x.Name, _stringComparison)))
{
var matchStart = prefix + matchedStartSrcProp.Name;
if (string.Equals(destProp.Name, matchStart, _stringComparison))
Expand All @@ -69,25 +69,25 @@ private void ScanSourceClassRecursively(IEnumerable<PropertyInfo> sourceProps, P
Mapper.MapExists(matchedStartSrcProp.PropertyType, destProp.PropertyType))
{
//matched a) same type, or b) dest is a nullable version of source
_foundFlattens.Add( new FlattenMemberInfo(destProp, sourcePropPath, matchedStartSrcProp));
_foundFlattens.Add(new FlattenMemberInfo(destProp, sourcePropPath, matchedStartSrcProp));
_filteredDestProps.Remove(destProp); //matched, so take it out
}

return;
}

if (matchedStartSrcProp.PropertyType == typeof (string))
if (matchedStartSrcProp.PropertyType == typeof(string))
//string can only be directly matched
continue;

if (matchedStartSrcProp.PropertyType.IsClass)
if (matchedStartSrcProp.PropertyType.GetInfo().IsClass)
{
var classProps = GetPropertiesRightAccess(matchedStartSrcProp.PropertyType);
var clonedList = sourcePropPath.ToList();
clonedList.Add(matchedStartSrcProp);
ScanSourceClassRecursively(classProps, destProp, matchStart, clonedList.ToArray());
}
else if (matchedStartSrcProp.PropertyType.GetInterfaces().Any(i => i.Name == "IEnumerable"))
else if (matchedStartSrcProp.PropertyType.GetInfo().GetInterfaces().Any(i => i.Name == "IEnumerable"))
{
//its an enumerable class so see if the end relates to a LINQ method
var endOfName = destProp.Name.Substring(matchStart.Length);
Expand All @@ -103,12 +103,12 @@ private void ScanSourceClassRecursively(IEnumerable<PropertyInfo> sourceProps, P

private static PropertyInfo[] GetPropertiesRightAccess<T>()
{
return GetPropertiesRightAccess(typeof (T));
return GetPropertiesRightAccess(typeof(T));
}

private static PropertyInfo[] GetPropertiesRightAccess(Type classType)
{
return classType.GetProperties(BindingFlags.Instance | BindingFlags.Public);
return classType.GetInfo().GetProperties(BindingFlags.Instance | BindingFlags.Public);
}

private List<PropertyInfo> FilterOutExactMatches(PropertyInfo[] propsToFilter, PropertyInfo[] filterAgainst)
Expand Down
135 changes: 0 additions & 135 deletions ExpressMapper NET40/Ioc/DependencyResolver.cs

This file was deleted.

10 changes: 0 additions & 10 deletions ExpressMapper NET40/Ioc/IContainer.cs

This file was deleted.

Loading

0 comments on commit 64d65b0

Please sign in to comment.