Skip to content

Commit 1689142

Browse files
committed
Initial Commit
0 parents  commit 1689142

18 files changed

+817
-0
lines changed

.gitignore

Lines changed: 190 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,190 @@
1+
## Ignore Visual Studio temporary files, build results, and
2+
## files generated by popular Visual Studio add-ons.
3+
4+
# User-specific files
5+
*.suo
6+
*.user
7+
*.sln.docstates
8+
9+
# Build results
10+
[Dd]ebug/
11+
[Dd]ebugPublic/
12+
[Rr]elease/
13+
x64/
14+
build/
15+
bld/
16+
[Bb]in/
17+
[Oo]bj/
18+
19+
# Roslyn cache directories
20+
*.ide/
21+
22+
# MSTest test Results
23+
[Tt]est[Rr]esult*/
24+
[Bb]uild[Ll]og.*
25+
26+
#NUNIT
27+
*.VisualState.xml
28+
TestResult.xml
29+
30+
# Build Results of an ATL Project
31+
[Dd]ebugPS/
32+
[Rr]eleasePS/
33+
dlldata.c
34+
35+
*_i.c
36+
*_p.c
37+
*_i.h
38+
*.ilk
39+
*.meta
40+
*.obj
41+
*.pch
42+
*.pdb
43+
*.pgc
44+
*.pgd
45+
*.rsp
46+
*.sbr
47+
*.tlb
48+
*.tli
49+
*.tlh
50+
*.tmp
51+
*.tmp_proj
52+
*.log
53+
*.vspscc
54+
*.vssscc
55+
.builds
56+
*.pidb
57+
*.svclog
58+
*.scc
59+
60+
# Chutzpah Test files
61+
_Chutzpah*
62+
63+
# Visual C++ cache files
64+
ipch/
65+
*.aps
66+
*.ncb
67+
*.opensdf
68+
*.sdf
69+
*.cachefile
70+
71+
# Visual Studio profiler
72+
*.psess
73+
*.vsp
74+
*.vspx
75+
76+
# TFS 2012 Local Workspace
77+
$tf/
78+
79+
# Guidance Automation Toolkit
80+
*.gpState
81+
82+
# ReSharper is a .NET coding add-in
83+
_ReSharper*/
84+
*.[Rr]e[Ss]harper
85+
*.DotSettings.user
86+
87+
# JustCode is a .NET coding addin-in
88+
.JustCode
89+
90+
# TeamCity is a build add-in
91+
_TeamCity*
92+
93+
# DotCover is a Code Coverage Tool
94+
*.dotCover
95+
96+
# NCrunch
97+
_NCrunch_*
98+
.*crunch*.local.xml
99+
100+
# MightyMoose
101+
*.mm.*
102+
AutoTest.Net/
103+
104+
# Web workbench (sass)
105+
.sass-cache/
106+
107+
# Installshield output folder
108+
[Ee]xpress/
109+
110+
# DocProject is a documentation generator add-in
111+
DocProject/buildhelp/
112+
DocProject/Help/*.HxT
113+
DocProject/Help/*.HxC
114+
DocProject/Help/*.hhc
115+
DocProject/Help/*.hhk
116+
DocProject/Help/*.hhp
117+
DocProject/Help/Html2
118+
DocProject/Help/html
119+
120+
# Click-Once directory
121+
publish/
122+
123+
# Publish Web Output
124+
*.[Pp]ublish.xml
125+
*.azurePubxml
126+
## TODO: Comment the next line if you want to checkin your
127+
## web deploy settings but do note that will include unencrypted
128+
## passwords
129+
#*.pubxml
130+
131+
# NuGet Packages Directory
132+
packages/*
133+
## TODO: If the tool you use requires repositories.config
134+
## uncomment the next line
135+
#!packages/repositories.config
136+
137+
# Enable "build/" folder in the NuGet Packages folder since
138+
# NuGet packages use it for MSBuild targets.
139+
# This line needs to be after the ignore of the build folder
140+
# (and the packages folder if the line above has been uncommented)
141+
!packages/build/
142+
143+
# Windows Azure Build Output
144+
csx/
145+
*.build.csdef
146+
147+
# Windows Store app package directory
148+
AppPackages/
149+
150+
# Others
151+
sql/
152+
*.Cache
153+
ClientBin/
154+
[Ss]tyle[Cc]op.*
155+
~$*
156+
*~
157+
*.dbmdl
158+
*.dbproj.schemaview
159+
*.pfx
160+
*.publishsettings
161+
node_modules/
162+
163+
# RIA/Silverlight projects
164+
Generated_Code/
165+
166+
# Backup & report files from converting an old project file
167+
# to a newer Visual Studio version. Backup files are not needed,
168+
# because we have git ;-)
169+
_UpgradeReport_Files/
170+
Backup*/
171+
UpgradeLog*.XML
172+
UpgradeLog*.htm
173+
174+
# SQL Server files
175+
*.mdf
176+
*.ldf
177+
178+
# Business Intelligence projects
179+
*.rdl.data
180+
*.bim.layout
181+
*.bim_*.settings
182+
183+
# Microsoft Fakes
184+
FakesAssemblies/
185+
186+
# LightSwitch generated files
187+
GeneratedArtifacts/
188+
_Pvt_Extensions/
189+
ModelManifest.xml
190+
*.dll
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 2013
4+
VisualStudioVersion = 12.0.31101.0
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutoMapper.Collection", "AutoMapper.Collection\AutoMapper.Collection.csproj", "{37AD667A-8080-476C-88FD-20310AC7CAF3}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{37AD667A-8080-476C-88FD-20310AC7CAF3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{37AD667A-8080-476C-88FD-20310AC7CAF3}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{37AD667A-8080-476C-88FD-20310AC7CAF3}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{37AD667A-8080-476C-88FD-20310AC7CAF3}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
EndGlobal
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{37AD667A-8080-476C-88FD-20310AC7CAF3}</ProjectGuid>
8+
<OutputType>Library</OutputType>
9+
<AppDesignerFolder>Properties</AppDesignerFolder>
10+
<RootNamespace>AutoMapper.Collection</RootNamespace>
11+
<AssemblyName>AutoMapper.Collection</AssemblyName>
12+
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
13+
<FileAlignment>512</FileAlignment>
14+
</PropertyGroup>
15+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
16+
<DebugSymbols>true</DebugSymbols>
17+
<DebugType>full</DebugType>
18+
<Optimize>false</Optimize>
19+
<OutputPath>bin\Debug\</OutputPath>
20+
<DefineConstants>DEBUG;TRACE</DefineConstants>
21+
<ErrorReport>prompt</ErrorReport>
22+
<WarningLevel>4</WarningLevel>
23+
</PropertyGroup>
24+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
25+
<DebugType>pdbonly</DebugType>
26+
<Optimize>true</Optimize>
27+
<OutputPath>bin\Release\</OutputPath>
28+
<DefineConstants>TRACE</DefineConstants>
29+
<ErrorReport>prompt</ErrorReport>
30+
<WarningLevel>4</WarningLevel>
31+
</PropertyGroup>
32+
<ItemGroup>
33+
<Reference Include="AutoMapper">
34+
<HintPath>..\packages\AutoMapper.3.3.1\lib\net40\AutoMapper.dll</HintPath>
35+
</Reference>
36+
<Reference Include="AutoMapper.Net4">
37+
<HintPath>..\packages\AutoMapper.3.3.1\lib\net40\AutoMapper.Net4.dll</HintPath>
38+
</Reference>
39+
<Reference Include="System" />
40+
<Reference Include="System.Core" />
41+
<Reference Include="System.Xml.Linq" />
42+
<Reference Include="System.Data.DataSetExtensions" />
43+
<Reference Include="Microsoft.CSharp" />
44+
<Reference Include="System.Data" />
45+
<Reference Include="System.Xml" />
46+
</ItemGroup>
47+
<ItemGroup>
48+
<Compile Include="Class1.cs" />
49+
<Compile Include="CustomExpressionVisitor.cs" />
50+
<Compile Include="EquivilentExpression.cs" />
51+
<Compile Include="EquivilentExpressions.cs" />
52+
<Compile Include="ExpressionExtentions.cs" />
53+
<Compile Include="GenerateEquivilentExpressionFromTypeMap.cs" />
54+
<Compile Include="GenerateEquivilentExpressionOnPropertyMaps.cs" />
55+
<Compile Include="GenerateEquivilentExpressions.cs" />
56+
<Compile Include="GenerateEquivilentExpressionsBasedOnGeneratePropertyMaps.cs" />
57+
<Compile Include="IEquivilentExpression.cs" />
58+
<Compile Include="IGenerateEquivilentExpressions.cs" />
59+
<Compile Include="IGeneratePropertyMaps.cs" />
60+
<Compile Include="Properties\AssemblyInfo.cs" />
61+
<Compile Include="UserDefinedEquivilentExpressions.cs" />
62+
</ItemGroup>
63+
<ItemGroup>
64+
<None Include="packages.config" />
65+
</ItemGroup>
66+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
67+
<Import Project="..\packages\AutoMapper.3.3.1\tools\AutoMapper.targets" Condition="Exists('..\packages\AutoMapper.3.3.1\tools\AutoMapper.targets')" />
68+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
69+
Other similar extension points exist, see Microsoft.Common.targets.
70+
<Target Name="BeforeBuild">
71+
</Target>
72+
<Target Name="AfterBuild">
73+
</Target>
74+
-->
75+
</Project>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
6+
namespace AutoMapper.Collection
7+
{
8+
public class Class1
9+
{
10+
}
11+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Linq.Expressions;
5+
using System.Reflection;
6+
7+
namespace AutoMapper.EquivilencyExpression
8+
{
9+
internal class CustomExpressionVisitor : ExpressionVisitor
10+
{
11+
readonly ParameterExpression _parameter;
12+
private readonly IEnumerable<PropertyMap> _propertyMaps;
13+
14+
internal CustomExpressionVisitor(ParameterExpression parameter, IEnumerable<PropertyMap> propertyMaps)
15+
{
16+
_parameter = parameter;
17+
_propertyMaps = propertyMaps;
18+
}
19+
20+
protected override Expression VisitParameter(ParameterExpression node)
21+
{
22+
return _parameter;
23+
}
24+
25+
protected override Expression VisitMember(MemberExpression node)
26+
{
27+
if (node.Member is PropertyInfo)
28+
{
29+
var matchPM = _propertyMaps.FirstOrDefault(pm => pm.DestinationProperty.MemberInfo == node.Member);
30+
if (matchPM == null)
31+
throw new Exception("No matching PropertyMap");
32+
var sourceValueResolvers = matchPM.GetSourceValueResolvers();
33+
if (!sourceValueResolvers.All(r => r is IMemberGetter))
34+
throw new Exception("Not all member getters");
35+
36+
var memberGetters = sourceValueResolvers.OfType<IMemberGetter>();
37+
var memberExpression = Expression.Property(Visit(node.Expression), memberGetters.First().MemberInfo as PropertyInfo);
38+
39+
foreach (var memberGetter in memberGetters.Skip(1))
40+
memberExpression = Expression.Property(memberExpression, memberGetter.MemberInfo as PropertyInfo);
41+
return memberExpression;
42+
}
43+
return base.VisitMember(node);
44+
}
45+
}
46+
}

0 commit comments

Comments
 (0)