目录

介绍

背景

如何使用?

与其他映射器的比较

性能!!!

初始配置

定制化

多种设定

映射测试用例

深入研究生成的表达式树


介绍

四年前,我用IL代码创建了对象映射器的初始版本。就在几周前,我决定使用Expression Tree来重新HigLabo.Mapper,实现了巨大的性能提升。它目前在世界上得分最高。您可以在https://github.com/higty/higlabo.netstandard/tree/master/HigLabo.Mapper上查看我的10天提交日志。

我共享我的代码和库,以为C#和.NET社区做出贡献。

可以在https://github.com/higty/higlabo/tree/master/NetStandard/HigLabo.Mapper中找到源代码。

您可以从Nuget中使用。

HigLabo.Mapper (版本3.0.2)

背景

如今,无论您是Web,Desktop,Mobile的开发人员,都可以使用POCO,DTO对象。而且,您必须在对象之间传递属性值。对象映射器对于这种情况很有用。这次,我重新实现的目标如下所示:

  1. 世界上最快
  2. 零配置提高生产力
  3. 全面定制各种用例
  4. 应用程序的多重映射规则

如何使用?

您可以从Nuget软件包中获得HigLabo.Mapper(3.0.0版或更高版本)。(旧版HigLabo.Mapper移至HigLabo.Mapper.ObjectMapConfig package。)

在您的应用程序中添加using指令:

using HigLabo.Core;

现在,您可以使用如下Map扩展方法:

var a1 = new Address(); //your POCO class.
var a2 = a1.Map(new Address());

HigLabo.Mapper 支持字典到对象的映射。

var d = new Dictionary<String, String>();
d["Name"] = "Bill";
var person = d.Map(new Person());
//person.Name is "Bill"

还支持对象到字典。

var p = new Person();
p.Name = "Bill";
var d = p.Map(new Dictionary<String, String>);
//d["Name"] is "Bill"

我设计HigLabo.Mapper易于使用。

与其他映射器的比较

在本章中,我将解释与其他映射器库的区别。这是比较的摘要。

  1. 性能
  2. 初始配置
  3. 定制化
  4. 多种设定

性能!!!

这对于mapper库很重要,因为它倾向于在更深的地方(如内部循环)使用。性能测试的摘要在这里。

  • AutoMapper34(对于没有集合属性的POCO)
  • Mapster10-20(对于没有集合属性的POCO)
  • AgileMapperFastMapperTinyMapper710(适用于没有集合属性的POCO)
  • AutoMapper3(对于具有集合属性的POCO)
  • Mapster10倍(对于具有集合属性的POCO
  • AgileMapperFastMapperTinyMapper1020(对于具有集合属性的POCO)

这是BenchmarkDotNet的性能测试结果。HigLaboObjectMapper_XXXX是新的HigLabo.Mapper的结果  。

这是用于性能测试的类。

public class Address
{public int Id { get; set; }public string Street { get; set; }public string City { get; set; }public string Country { get; set; }public AddressType AddressType { get; set; }
}public class AddressDTO
{public int Id { get; set; }public string City { get; set; }public string Country { get; set; }public AddressType AddressType { get; set; } = AddressType.House;
}
public struct GpsPosition
{public double Latitude { get; private set; }public double Longitude { get; private set; }public GpsPosition(double latitude, double longitude){this.Latitude = latitude;this.Longitude = longitude;}
}public class Customer
{public Int32? Id { get; set; }public String Name { get; set; }public Address Address { get; set; }public Address HomeAddress { get; set; }public Address[] AddressList { get; set; }public IEnumerable<Address> WorkAddressList { get; set; }
}public class CustomerDTO
{public Int32? Id { get; set; }public string Name { get; set; }public Address Address { get; set; }public AddressDTO HomeAddress { get; set; }public AddressDTO[] AddressList { get; set; }public List<AddressDTO> WorkAddressList { get; set; }public String AddressCity { get; set; }
}

我测试了4种类型的映射,如下所示:

1. POCO class without collection property to same class.
XXX.Map(new Address(), new Address())2. POCO class without collection property to other class.
XXX.Map(new Address(), new AddressDTO())3. POCO class that has collection property map to same class.
XXX.Map(new Customer(), new Customer())4. POCO class that has collection property map to other class.
XXX.Map(new Customer(), new CustomerDTO());

如您所见,这4种情况HigLabo.Mapper都是最快的。

您可以在https://github.com/higty/higlabo/tree/master/NetStandard/HigLabo.Test/HigLabo.Mapper.PerformanceTest查看完整的测试代码  。

初始配置

一些Mapper需要这样的初始配置:

var configuration = new AutoMapper.MapperConfiguration(config => {config.CreateMap<Building, Building>();config.CreateMap<TreeNode, TreeNode>();
});

这是AutoMapper配置代码。如果您有成千上万个要映射的类,那么创建此映射配置代码将很无聊。TinyMapper也需要配置。

TinyMapper.Bind<Park, Park>();
TinyMapper.Bind<Customer, CustomerDTO>();
TinyMapper.Bind<Dictionary<String, String>, Building>();

HigLabo.Mapper不需要任何配置。您可以直接使用它。

定制化

有时,您想针对POCO对象自定义映射规则。自定义映射规则太复杂了。我将在该页面的示例进行AutoMapper与HigLabo.Mapper比较。

https://stackoverflow.com/questions/50964757/delegating-member-mapping-to-child-object-with-automapper

class Source {public int Id {get;set;}public int UseThisInt {get;set;}public InnerType Inner {get;set;}// other properties that the Destination class is not interested in
}
class InnerType {public int Id {get;set;}public int Height {get;set;}// more inner properties
}
class Destination {public int Id {get;set;}public int UseThisInt {get;set;}public int Height {get;set;}// more inner properties that should map to InnerType
}//So many configuration and complicated....
Mapper.Initialize(cfg => {cfg.CreateMap<source, destination="">();cfg.CreateMap<innertype, destination="">();
});
var dest = Mapper.Map<destination>(src);
Mapper.Map(src.Inner, dest);
Mapper.Initialize(cfg => {cfg.CreateMap<source, destination="">()AfterMap((src, dest) => Mapper.Map(src.Inner, dest));cfg.CreateMap<innertype, destination="">();});
var dest = Mapper.Map<destination>(src);

如果你使用AutoMapper,你必须了解AutoMapper库和Mapper.Initialize,ForMember,CreateMap,AfterMap等一样。

HigLabo.Mapper 可以这样定制:

c.AddPostAction<Source, Destination>((s, d) =>
{d.Id = s.Inner.Id;//Set Inner object property to Destination object     s.Inner.Map(d);
});

当你调用Map方法时, HigLabo.Mapper只在完成映射后调用此lambda 。因此,您可以覆盖默认映射规则。

您可以使用以下ReplaceMap方法完全替换映射规则:

c.ReplaceMap<Source, Destination>((s, d) =>
{//Set all map with your own.d.Id = s.Inner.Id;//Set Inner object property to Destination objects.Inner.Map(d);
});
//You can call Map method.
var source = new Source();
var destination = new Destination();
source.Map(distination); //Above lambda will be called.

它很简单,不需要其他知识。您只能知道已经使用的C# lambda。

您可以轻松添加转换逻辑。

c.AddPostAction<Person, PersonVM>((s, d) =>
{d.BMI = CalculateBMI(s.Height, s.Weight);
});

您还可以使用条件属性映射。

c.AddPostAction<Employee, EmployeeVM>((s, d) =>
{if (s.EmployeeType == EmployeeType.Contract){d.Property1 = someValue1;}else{d.Property1 = someValue2;}
});

这种设计的另一个优点是,您可以轻松地调试代码。您可以在AddPostAction,ReplaceMap方法中的lambda 上设置断点。

您还可以像这样自定义属性映射规则:

class Person
{public string Name { get; set; }public string Position_Name { get; set; }
}
class PersonModel
{public string Name { get; set; }public string PositionName { get; set; }
}var mapper = HigLabo.Core.ObjectMapper.Default;
mapper.CompilerConfig.PropertyMatchRule = (sourceType, sourceProperty, targetType, targetProperty)
{if (sourceType == typeof(Person) && targetType == typeof(PersonModel)){return sourceProperty.Name.Replace("_", "") == targetProperty.Name;}return false;
};

多种设定

您可以创建ObjectMapper类的多个实例。

var om1 = new ObjectMapper();
om1.AddPostAction<Address, Address>((s, d) =>
{//Custom map rule
});var om2 = new ObjectMapper();
om2.AddPostAction<Address, Address>((s, d) =>
{//Another Custom map rule
});var a = new Address();
var a1 = om1.Map(a, new Address());
var a2 = om1.Map(a, new Address());

Map扩展方法被声明为ObjectMapperExtensions类。此方法仅调用ObjectMapper.Default实例方法。

using System;namespace HigLabo.Core
{public static class ObjectMapperExtensions{public static TTarget Map<TSource, TTarget>(this TSource source, TTarget target){return ObjectMapper.Default.Map(source, target);}public static TTarget MapOrNull<TSource, TTarget>(this TSource source, Func<TTarget> targetConstructor)where TTarget : class{return ObjectMapper.Default.MapOrNull(source, targetConstructor);}public static TTarget MapOrNull<TSource, TTarget>(this TSource source, TTarget target)where TTarget : class{return ObjectMapper.Default.MapOrNull(source, target);}public static TTarget MapFrom<TTarget, TSource>(this TTarget target, TSource source){return ObjectMapper.Default.Map(source, target);}}
}

因此,您可以创建一个新实例并添加新规则并使用它。

您可以像这样封装初始化代码:

public static class ObjectMapperExtensions
{public static void Initialize(this ObjectMapper mapper){mapper.AddPostAction<Address, Address>((s, d) =>{//Your mapping rule.});mapper.AddPostAction<Address, Address>((s, d) =>{//Another your mapping rule.});}
}//And call it on Application initialization process.
ObjectMapper.Default.Initialize();

映射测试用例

我在这里创建了所有测试用例:

  • https://github.com/higty/higlabo/tree/master/NetStandard/HigLabo.Test/HigLabo.Mapper.Test

我测试了先前版本支持的所有情况,但字典自定义映射的情况除外。

但是我认为,可能包括casse异常的一些罕见情况,因为这是初始版本。如果遇到异常,请随时在GitHub issue上询问我。

深入研究生成的表达式树

测试用例在这里。

https://github.com/higty/higlabo/tree/master/NetStandard/HigLabo.Test/HigLabo.Mapper.Test

ObjectMapper_Map_ValueType_ValueType 测试用例将使用表达式树生成以下代码。

.Lambda #Lambda1<System.Func`3[System.Object,System.Object,HigLabo.Mapper.Test.Vector2]>(System.Object $sourceParameter,System.Object $targetParameter) {.Block(HigLabo.Mapper.Test.Vector2 $source,HigLabo.Mapper.Test.Vector2 $target) {$source = .Unbox($sourceParameter);$target = .Unbox($targetParameter);.Call $target.set_X($source.X);.Call $target.set_Y($source.Y);$target}
}

AddressDTO的地址将生成此表达式树作为MapAction Func。

.Lambda #Lambda1<System.Func`3[System.Object,System.Object,HigLabo.Mapper.PerformanceTest.AddressDTO]>(System.Object $sourceParameter,System.Object $targetParameter) {.Block(HigLabo.Mapper.PerformanceTest.Address $source,HigLabo.Mapper.PerformanceTest.AddressDTO $target) {$source = $sourceParameter .As HigLabo.Mapper.PerformanceTest.Address;$target = $targetParameter .As HigLabo.Mapper.PerformanceTest.AddressDTO;.Call $target.set_Id($source.Id);.Call $target.set_City($source.City);.Call $target.set_Country($source.Country);.Call $target.set_AddressType($source.AddressType);$target}
}

ObjectMapper_Map_CollectionElementCreateMode_CollectionElementCreateMode_NewObject 将生成以下代码:

.Lambda #Lambda1<System.Func`3[System.Object,System.Object,HigLabo.Mapper.Test.User]>(System.Object $sourceParameter,System.Object $targetParameter) {.Block(HigLabo.Mapper.Test.User $source,HigLabo.Mapper.Test.User $target) {$source = $sourceParameter .As HigLabo.Mapper.Test.User;$target = $targetParameter .As HigLabo.Mapper.Test.User;.Call $target.set_Value($source.Value);.Call $target.set_Name($source.Name);.Call $target.set_Int32($source.Int32);.Call $target.set_Int32Nullable($source.Int32Nullable);.Call $target.set_Int32_Nullable($source.Int32_Nullable);.Call $target.set_Int32NullableToInt32($source.Int32NullableToInt32);.Call $target.set_DateTime($source.DateTime);.Call $target.set_DateTimeNullable($source.DateTimeNullable);.Call $target.set_Decimal($source.Decimal);.Call $target.set_DecimalNullable($source.DecimalNullable);.Call $target.set_DayOfWeek($source.DayOfWeek);.Call $target.set_DayOfWeekNullable($source.DayOfWeekNullable);.Call $target.set_Guid($source.Guid);.Call $target.set_GuidNullable($source.GuidNullable);.If ($source.MapPoint == null) {.Call $target.set_MapPoint(.Default(HigLabo.Mapper.Test.MapPoint))} .Else {.Block() {.If ($target.MapPoint == null) {$target.MapPoint = .New HigLabo.Mapper.Test.MapPoint()} .Else {.Default(System.Void)};.Call ($target.MapPoint).set_Longitude(($source.MapPoint).Longitude);.Call ($target.MapPoint).set_Latitude(($source.MapPoint).Latitude)}};.Call $target.set_VectorToNullable($source.VectorToNullable);.Call $target.set_Vector2($source.Vector2);.If ($source.ParentUser == null) {.Call $target.set_ParentUser(.Default(HigLabo.Mapper.Test.User))} .Else {.Block() {.If ($target.ParentUser == null) {$target.ParentUser = .New HigLabo.Mapper.Test.User()} .Else {.Default(System.Void)};.Call ($target.ParentUser).set_Value(($source.ParentUser).Value);.Call ($target.ParentUser).set_Name(($source.ParentUser).Name);.Call ($target.ParentUser).set_Int32(($source.ParentUser).Int32);.Call ($target.ParentUser).set_Int32Nullable(($source.ParentUser).Int32Nullable);.Call ($target.ParentUser).set_Int32_Nullable(($source.ParentUser).Int32_Nullable);.Call ($target.ParentUser).set_Int32NullableToInt32(($source.ParentUser).Int32NullableToInt32);.Call ($target.ParentUser).set_DateTime(($source.ParentUser).DateTime);.Call ($target.ParentUser).set_DateTimeNullable(($source.ParentUser).DateTimeNullable);.Call ($target.ParentUser).set_Decimal(($source.ParentUser).Decimal);.Call ($target.ParentUser).set_DecimalNullable(($source.ParentUser).DecimalNullable);.Call ($target.ParentUser).set_DayOfWeek(($source.ParentUser).DayOfWeek);.Call ($target.ParentUser).set_DayOfWeekNullable(($source.ParentUser).DayOfWeekNullable);.Call ($target.ParentUser).set_Guid(($source.ParentUser).Guid);.Call ($target.ParentUser).set_GuidNullable(($source.ParentUser).GuidNullable);.If (($source.ParentUser).MapPoint == null) {.Call ($target.ParentUser).set_MapPoint(.Default(HigLabo.Mapper.Test.MapPoint))} .Else {.Block() {.If (($target.ParentUser).MapPoint == null) {($target.ParentUser).MapPoint = .New HigLabo.Mapper.Test.MapPoint()} .Else {.Default(System.Void)};.Call (($target.ParentUser).MapPoint).set_Longitude((($source.ParentUser).MapPoint).Longitude);.Call (($target.ParentUser).MapPoint).set_Latitude((($source.ParentUser).MapPoint).Latitude)}};.Call ($target.ParentUser).set_VectorToNullable(($source.ParentUser).VectorToNullable);.Call ($target.ParentUser).set_Vector2(($source.ParentUser).Vector2);.If (($source.ParentUser).ParentUser == null) {.Call ($target.ParentUser).set_ParentUser(.Default(HigLabo.Mapper.Test.User))} .Else {.Block() {.If (($target.ParentUser).ParentUser == null) {($target.ParentUser).ParentUser = .New HigLabo.Mapper.Test.User()} .Else {.Default(System.Void)};.Call (($target.ParentUser).ParentUser).set_Value((($source.ParentUser).ParentUser).Value);.Call (($target.ParentUser).ParentUser).set_Name((($source.ParentUser).ParentUser).Name);.Call (($target.ParentUser).ParentUser).set_Int32((($source.ParentUser).ParentUser).Int32);.Call (($target.ParentUser).ParentUser).set_Int32Nullable((($source.ParentUser).ParentUser).Int32Nullable);.Call (($target.ParentUser).ParentUser).set_Int32_Nullable((($source.ParentUser).ParentUser).Int32_Nullable);.Call (($target.ParentUser).ParentUser).set_Int32NullableToInt32((($source.ParentUser).ParentUser).Int32NullableToInt32);.Call (($target.ParentUser).ParentUser).set_DateTime((($source.ParentUser).ParentUser).DateTime);.Call (($target.ParentUser).ParentUser).set_DateTimeNullable((($source.ParentUser).ParentUser).DateTimeNullable);.Call (($target.ParentUser).ParentUser).set_Decimal((($source.ParentUser).ParentUser).Decimal);.Call (($target.ParentUser).ParentUser).set_DecimalNullable((($source.ParentUser).ParentUser).DecimalNullable);.Call (($target.ParentUser).ParentUser).set_DayOfWeek((($source.ParentUser).ParentUser).DayOfWeek);.Call (($target.ParentUser).ParentUser).set_DayOfWeekNullable((($source.ParentUser).ParentUser).DayOfWeekNullable);.Call (($target.ParentUser).ParentUser).set_Guid((($source.ParentUser).ParentUser).Guid);.Call (($target.ParentUser).ParentUser).set_GuidNullable((($source.ParentUser).ParentUser).GuidNullable);.If ((($source.ParentUser).ParentUser).MapPoint == null) {.Call (($target.ParentUser).ParentUser).set_MapPoint(.Default(HigLabo.Mapper.Test.MapPoint))} .Else {.Block() {.If ((($target.ParentUser).ParentUser).MapPoint == null) {(($target.ParentUser).ParentUser).MapPoint = .New HigLabo.Mapper.Test.MapPoint()} .Else {.Default(System.Void)};.Call ((($target.ParentUser).ParentUser).MapPoint).set_Longitude(((($source.ParentUser).ParentUser).MapPoint).Longitude);.Call ((($target.ParentUser).ParentUser).MapPoint).set_Latitude(((($source.ParentUser).ParentUser).MapPoint).Latitude)}};.Call (($target.ParentUser).ParentUser).set_VectorToNullable((($source.ParentUser).ParentUser).VectorToNullable);.Call (($target.ParentUser).ParentUser).set_Vector2((($source.ParentUser).ParentUser).Vector2);.If ((($source.ParentUser).ParentUser).ParentUser == null) {.Call (($target.ParentUser).ParentUser).set_ParentUser(.Default(HigLabo.Mapper.Test.User))} .Else {.Block() {.If ((($target.ParentUser).ParentUser).ParentUser == null) {(($target.ParentUser).ParentUser).ParentUser = .New HigLabo.Mapper.Test.User()} .Else {.Default(System.Void)};.Call ((($target.ParentUser).ParentUser).ParentUser).set_Value(((($source.ParentUser).ParentUser).ParentUser).Value);.Call ((($target.ParentUser).ParentUser).ParentUser).set_Name(((($source.ParentUser).ParentUser).ParentUser).Name);.Call ((($target.ParentUser).ParentUser).ParentUser).set_Int32(((($source.ParentUser).ParentUser).ParentUser).Int32);.Call ((($target.ParentUser).ParentUser).ParentUser).set_Int32Nullable(((($source.ParentUser).ParentUser).ParentUser).Int32Nullable);.Call ((($target.ParentUser).ParentUser).ParentUser).set_Int32_Nullable(((($source.ParentUser).ParentUser).ParentUser).Int32_Nullable);.Call ((($target.ParentUser).ParentUser).ParentUser).set_Int32NullableToInt32(((($source.ParentUser).ParentUser).ParentUser).Int32NullableToInt32);.Call ((($target.ParentUser).ParentUser).ParentUser).set_DateTime(((($source.ParentUser).ParentUser).ParentUser).DateTime);.Call ((($target.ParentUser).ParentUser).ParentUser).set_DateTimeNullable(((($source.ParentUser).ParentUser).ParentUser).DateTimeNullable);.Call ((($target.ParentUser).ParentUser).ParentUser).set_Decimal(((($source.ParentUser).ParentUser).ParentUser).Decimal);.Call ((($target.ParentUser).ParentUser).ParentUser).set_DecimalNullable(((($source.ParentUser).ParentUser).ParentUser).DecimalNullable);.Call ((($target.ParentUser).ParentUser).ParentUser).set_DayOfWeek(((($source.ParentUser).ParentUser).ParentUser).DayOfWeek);.Call ((($target.ParentUser).ParentUser).ParentUser).set_DayOfWeekNullable(((($source.ParentUser).ParentUser).ParentUser).DayOfWeekNullable);.Call ((($target.ParentUser).ParentUser).ParentUser).set_Guid(((($source.ParentUser).ParentUser).ParentUser).Guid);.Call ((($target.ParentUser).ParentUser).ParentUser).set_GuidNullable(((($source.ParentUser).ParentUser).ParentUser).GuidNullable);.If (((($source.ParentUser).ParentUser).ParentUser).MapPoint == null) {.Call ((($target.ParentUser).ParentUser).ParentUser).set_MapPoint(.Default(HigLabo.Mapper.Test.MapPoint))} .Else {.Block() {.If (((($target.ParentUser).ParentUser).ParentUser).MapPoint == null) {((($target.ParentUser).ParentUser).ParentUser).MapPoint = .New HigLabo.Mapper.Test.MapPoint()} .Else {.Default(System.Void)};.Call (((($target.ParentUser).ParentUser).ParentUser).MapPoint).set_Longitude((((($source.ParentUser).ParentUser).ParentUser).MapPoint).Longitude);.Call (((($target.ParentUser).ParentUser).ParentUser).MapPoint).set_Latitude((((($source.ParentUser).ParentUser).ParentUser).MapPoint).Latitude)}};.Call ((($target.ParentUser).ParentUser).ParentUser).set_VectorToNullable(((($source.ParentUser).ParentUser).ParentUser).VectorToNullable);.Call ((($target.ParentUser).ParentUser).ParentUser).set_Vector2(((($source.ParentUser).ParentUser).ParentUser).Vector2);.If (((($source.ParentUser).ParentUser).ParentUser).ParentUser == null) {.Call ((($target.ParentUser).ParentUser).ParentUser).set_ParentUser(.Default(HigLabo.Mapper.Test.User))} .Else {.Block() {.If (((($target.ParentUser).ParentUser).ParentUser).ParentUser == null) {((($target.ParentUser).ParentUser).ParentUser).ParentUser = .New HigLabo.Mapper.Test.User()} .Else {.Default(System.Void)};.Call (((($target.ParentUser).ParentUser).ParentUser).ParentUser).set_Value((((($source.ParentUser).ParentUser).ParentUser).ParentUser).Value);.Call (((($target.ParentUser).ParentUser).ParentUser).ParentUser).set_Name((((($source.ParentUser).ParentUser).ParentUser).ParentUser).Name);.Call (((($target.ParentUser).ParentUser).ParentUser).ParentUser).set_Int32((((($source.ParentUser).ParentUser).ParentUser).ParentUser).Int32);.Call (((($target.ParentUser).ParentUser).ParentUser).ParentUser).set_Int32Nullable((((($source.ParentUser).ParentUser).ParentUser).ParentUser).Int32Nullable);.Call (((($target.ParentUser).ParentUser).ParentUser).ParentUser).set_Int32_Nullable((((($source.ParentUser).ParentUser).ParentUser).ParentUser).Int32_Nullable);.Call (((($target.ParentUser).ParentUser).ParentUser).ParentUser).set_Int32NullableToInt32((((($source.ParentUser).ParentUser).ParentUser).ParentUser).Int32NullableToInt32);.Call (((($target.ParentUser).ParentUser).ParentUser).ParentUser).set_DateTime((((($source.ParentUser).ParentUser).ParentUser).ParentUser).DateTime);.Call (((($target.ParentUser).ParentUser).ParentUser).ParentUser).set_DateTimeNullable((((($source.ParentUser).ParentUser).ParentUser).ParentUser).DateTimeNullable);.Call (((($target.ParentUser).ParentUser).ParentUser).ParentUser).set_Decimal((((($source.ParentUser).ParentUser).ParentUser).ParentUser).Decimal);.Call (((($target.ParentUser).ParentUser).ParentUser).ParentUser).set_DecimalNullable((((($source.ParentUser).ParentUser).ParentUser).ParentUser).DecimalNullable);.Call (((($target.ParentUser).ParentUser).ParentUser).ParentUser).set_DayOfWeek((((($source.ParentUser).ParentUser).ParentUser).ParentUser).DayOfWeek);.Call (((($target.ParentUser).ParentUser).ParentUser).ParentUser).set_DayOfWeekNullable((((($source.ParentUser).ParentUser).ParentUser).ParentUser).DayOfWeekNullable);.Call (((($target.ParentUser).ParentUser).ParentUser).ParentUser).set_Guid((((($source.ParentUser).ParentUser).ParentUser).ParentUser).Guid);.Call (((($target.ParentUser).ParentUser).ParentUser).ParentUser).set_GuidNullable((((($source.ParentUser).ParentUser).ParentUser).ParentUser).GuidNullable);.If ((((($source.ParentUser).ParentUser).ParentUser).ParentUser).MapPoint == null) {.Call (((($target.ParentUser).ParentUser).ParentUser).ParentUser).set_MapPoint(.Default(HigLabo.Mapper.Test.MapPoint))} .Else {.Block() {.If ((((($target.ParentUser).ParentUser).ParentUser).ParentUser).MapPoint == null) {(((($target.ParentUser).ParentUser).ParentUser).ParentUser).MapPoint = .New HigLabo.Mapper.Test.MapPoint()} .Else {.Default(System.Void)}}};.Call (((($target.ParentUser).ParentUser).ParentUser).ParentUser).set_VectorToNullable((((($source.ParentUser).ParentUser).ParentUser).ParentUser).VectorToNullable);.Call (((($target.ParentUser).ParentUser).ParentUser).ParentUser).set_Vector2((((($source.ParentUser).ParentUser).ParentUser).ParentUser).Vector2);.If ((((($source.ParentUser).ParentUser).ParentUser).ParentUser).ParentUser == null) {.Call (((($target.ParentUser).ParentUser).ParentUser).ParentUser).set_ParentUser(.Default(HigLabo.Mapper.Test.User))} .Else {.Block() {.If ((((($target.ParentUser).ParentUser).ParentUser).ParentUser).ParentUser == null) {(((($target.ParentUser).ParentUser).ParentUser).ParentUser).ParentUser = .New HigLabo.Mapper.Test.User()} .Else {.Default(System.Void)}}};.If ((((($source.ParentUser).ParentUser).ParentUser).ParentUser).Dictionary == null) {.Call (((($target.ParentUser).ParentUser).ParentUser).ParentUser).set_Dictionary(.Default(System.Collections.Generic.Dictionary`2[System.String,System.String]))} .Else {.Block() {.If ((((($target.ParentUser).ParentUser).ParentUser).ParentUser).Dictionary == null) {(((($target.ParentUser).ParentUser).ParentUser).ParentUser).Dictionary = .New System.Collections.Generic.Dictionary`2[System.String,System.String]()} .Else {.Default(System.Void)}}}}};.If (((($source.ParentUser).ParentUser).ParentUser).Dictionary == null) {.Call ((($target.ParentUser).ParentUser).ParentUser).set_Dictionary(.Default(System.Collections.Generic.Dictionary`2[System.String,System.String]))} .Else {.Block() {.If (((($target.ParentUser).ParentUser).ParentUser).Dictionary == null) {((($target.ParentUser).ParentUser).ParentUser).Dictionary = .New System.Collections.Generic.Dictionary`2[System.String,System.String]()} .Else {.Default(System.Void)}}}}};.If ((($source.ParentUser).ParentUser).Dictionary == null) {.Call (($target.ParentUser).ParentUser).set_Dictionary(.Default(System.Collections.Generic.Dictionary`2[System.String,System.String]))} .Else {.Block() {.If ((($target.ParentUser).ParentUser).Dictionary == null) {(($target.ParentUser).ParentUser).Dictionary = .New System.Collections.Generic.Dictionary`2[System.String,System.String]()} .Else {.Default(System.Void)}}}}};.If (($source.ParentUser).Dictionary == null) {.Call ($target.ParentUser).set_Dictionary(.Default(System.Collections.Generic.Dictionary`2[System.String,System.String]))} .Else {.Block() {.If (($target.ParentUser).Dictionary == null) {($target.ParentUser).Dictionary = .New System.Collections.Generic.Dictionary`2[System.String,System.String]()} .Else {.Default(System.Void)}}}}};.If ($source.Dictionary == null) {.Call $target.set_Dictionary(.Default(System.Collections.Generic.Dictionary`2[System.String,System.String]))} .Else {.Block() {.If ($target.Dictionary == null) {$target.Dictionary = .New System.Collections.Generic.Dictionary`2[System.String,System.String]()} .Else {.Default(System.Void)}}};.If ($target.Users == null) {.Call $target.set_Users(.New System.Collections.Generic.List`1[HigLabo.Mapper.Test.User]())} .Else {.Default(System.Void)};.Block(HigLabo.Mapper.Test.User $sourceElement,HigLabo.Mapper.Test.User $targetElement,System.Int32 $i) {$i;.If ($source.Users == null) {.Return end { }} .Else {.Default(System.Void)};$i = 0;.Loop  {.Block() {.If (($source.Users).Count <= $i) {.Break endLoop { }} .Else {.Default(System.Void)};$sourceElement = ($source.Users).Item[$i];$targetElement = .New HigLabo.Mapper.Test.User();.Call $targetElement.set_Value($sourceElement.Value);.Call $targetElement.set_Name($sourceElement.Name);.Call $targetElement.set_Int32($sourceElement.Int32);.Call $targetElement.set_Int32Nullable($sourceElement.Int32Nullable);.Call $targetElement.set_Int32_Nullable($sourceElement.Int32_Nullable);.Call $targetElement.set_Int32NullableToInt32($sourceElement.Int32NullableToInt32);.Call $targetElement.set_DateTime($sourceElement.DateTime);.Call $targetElement.set_DateTimeNullable($sourceElement.DateTimeNullable);.Call $targetElement.set_Decimal($sourceElement.Decimal);.Call $targetElement.set_DecimalNullable($sourceElement.DecimalNullable);.Call $targetElement.set_DayOfWeek($sourceElement.DayOfWeek);.Call $targetElement.set_DayOfWeekNullable($sourceElement.DayOfWeekNullable);.Call $targetElement.set_Guid($sourceElement.Guid);.Call $targetElement.set_GuidNullable($sourceElement.GuidNullable);.If ($sourceElement.MapPoint == null) {.Call $targetElement.set_MapPoint(.Default(HigLabo.Mapper.Test.MapPoint))} .Else {.Block() {.If ($targetElement.MapPoint == null) {$targetElement.MapPoint = .New HigLabo.Mapper.Test.MapPoint()} .Else {.Default(System.Void)};.Call ($targetElement.MapPoint).set_Longitude(($sourceElement.MapPoint).Longitude);.Call ($targetElement.MapPoint).set_Latitude(($sourceElement.MapPoint).Latitude)}};.Call $targetElement.set_VectorToNullable($sourceElement.VectorToNullable);.Call $targetElement.set_Vector2($sourceElement.Vector2);.If ($sourceElement.ParentUser == null) {.Call $targetElement.set_ParentUser(.Default(HigLabo.Mapper.Test.User))} .Else {.Block() {.If ($targetElement.ParentUser == null) {$targetElement.ParentUser = .New HigLabo.Mapper.Test.User()} .Else {.Default(System.Void)};.Call ($targetElement.ParentUser).set_Value(($sourceElement.ParentUser).Value);.Call ($targetElement.ParentUser).set_Name(($sourceElement.ParentUser).Name);.Call ($targetElement.ParentUser).set_Int32(($sourceElement.ParentUser).Int32);.Call ($targetElement.ParentUser).set_Int32Nullable(($sourceElement.ParentUser).Int32Nullable);.Call ($targetElement.ParentUser).set_Int32_Nullable(($sourceElement.ParentUser).Int32_Nullable);.Call ($targetElement.ParentUser).set_Int32NullableToInt32(($sourceElement.ParentUser).Int32NullableToInt32);.Call ($targetElement.ParentUser).set_DateTime(($sourceElement.ParentUser).DateTime);.Call ($targetElement.ParentUser).set_DateTimeNullable(($sourceElement.ParentUser).DateTimeNullable);.Call ($targetElement.ParentUser).set_Decimal(($sourceElement.ParentUser).Decimal);.Call ($targetElement.ParentUser).set_DecimalNullable(($sourceElement.ParentUser).DecimalNullable);.Call ($targetElement.ParentUser).set_DayOfWeek(($sourceElement.ParentUser).DayOfWeek);.Call ($targetElement.ParentUser).set_DayOfWeekNullable(($sourceElement.ParentUser).DayOfWeekNullable);.Call ($targetElement.ParentUser).set_Guid(($sourceElement.ParentUser).Guid);.Call ($targetElement.ParentUser).set_GuidNullable(($sourceElement.ParentUser).GuidNullable);.If (($sourceElement.ParentUser).MapPoint == null) {.Call ($targetElement.ParentUser).set_MapPoint(.Default(HigLabo.Mapper.Test.MapPoint))} .Else {.Block() {.If (($targetElement.ParentUser).MapPoint == null) {($targetElement.ParentUser).MapPoint = .New HigLabo.Mapper.Test.MapPoint()} .Else {.Default(System.Void)};.Call (($targetElement.ParentUser).MapPoint).set_Longitude((($sourceElement.ParentUser).MapPoint).Longitude);.Call (($targetElement.ParentUser).MapPoint).set_Latitude((($sourceElement.ParentUser).MapPoint).Latitude)}};.Call ($targetElement.ParentUser).set_VectorToNullable(($sourceElement.ParentUser).VectorToNullable);.Call ($targetElement.ParentUser).set_Vector2(($sourceElement.ParentUser).Vector2);.If (($sourceElement.ParentUser).ParentUser == null) {.Call ($targetElement.ParentUser).set_ParentUser(.Default(HigLabo.Mapper.Test.User))} .Else {.Block() {.If (($targetElement.ParentUser).ParentUser == null) {($targetElement.ParentUser).ParentUser = .New HigLabo.Mapper.Test.User()} .Else {.Default(System.Void)};.Call (($targetElement.ParentUser).ParentUser).set_Value((($sourceElement.ParentUser).ParentUser).Value);.Call (($targetElement.ParentUser).ParentUser).set_Name((($sourceElement.ParentUser).ParentUser).Name);.Call (($targetElement.ParentUser).ParentUser).set_Int32((($sourceElement.ParentUser).ParentUser).Int32);.Call (($targetElement.ParentUser).ParentUser).set_Int32Nullable((($sourceElement.ParentUser).ParentUser).Int32Nullable);.Call (($targetElement.ParentUser).ParentUser).set_Int32_Nullable((($sourceElement.ParentUser).ParentUser).Int32_Nullable);.Call (($targetElement.ParentUser).ParentUser).set_Int32NullableToInt32((($sourceElement.ParentUser).ParentUser).Int32NullableToInt32);.Call (($targetElement.ParentUser).ParentUser).set_DateTime((($sourceElement.ParentUser).ParentUser).DateTime);.Call (($targetElement.ParentUser).ParentUser).set_DateTimeNullable((($sourceElement.ParentUser).ParentUser).DateTimeNullable);.Call (($targetElement.ParentUser).ParentUser).set_Decimal((($sourceElement.ParentUser).ParentUser).Decimal);.Call (($targetElement.ParentUser).ParentUser).set_DecimalNullable((($sourceElement.ParentUser).ParentUser).DecimalNullable);.Call (($targetElement.ParentUser).ParentUser).set_DayOfWeek((($sourceElement.ParentUser).ParentUser).DayOfWeek);.Call (($targetElement.ParentUser).ParentUser).set_DayOfWeekNullable((($sourceElement.ParentUser).ParentUser).DayOfWeekNullable);.Call (($targetElement.ParentUser).ParentUser).set_Guid((($sourceElement.ParentUser).ParentUser).Guid);.Call (($targetElement.ParentUser).ParentUser).set_GuidNullable((($sourceElement.ParentUser).ParentUser).GuidNullable);.If ((($sourceElement.ParentUser).ParentUser).MapPoint == null) {.Call (($targetElement.ParentUser).ParentUser).set_MapPoint(.Default(HigLabo.Mapper.Test.MapPoint))} .Else {.Block() {.If ((($targetElement.ParentUser).ParentUser).MapPoint == null) {(($targetElement.ParentUser).ParentUser).MapPoint = .New HigLabo.Mapper.Test.MapPoint()} .Else {.Default(System.Void)};.Call ((($targetElement.ParentUser).ParentUser).MapPoint).set_Longitude(((($sourceElement.ParentUser).ParentUser).MapPoint).Longitude);.Call ((($targetElement.ParentUser).ParentUser).MapPoint).set_Latitude(((($sourceElement.ParentUser).ParentUser).MapPoint).Latitude)}};.Call (($targetElement.ParentUser).ParentUser).set_VectorToNullable((($sourceElement.ParentUser).ParentUser).VectorToNullable);.Call (($targetElement.ParentUser).ParentUser).set_Vector2((($sourceElement.ParentUser).ParentUser).Vector2);.If ((($sourceElement.ParentUser).ParentUser).ParentUser == null) {.Call (($targetElement.ParentUser).ParentUser).set_ParentUser(.Default(HigLabo.Mapper.Test.User))} .Else {.Block() {.If ((($targetElement.ParentUser).ParentUser).ParentUser == null) {(($targetElement.ParentUser).ParentUser).ParentUser = .New HigLabo.Mapper.Test.User()} .Else {.Default(System.Void)};.Call ((($targetElement.ParentUser).ParentUser).ParentUser).set_Value(((($sourceElement.ParentUser).ParentUser).ParentUser).Value);.Call ((($targetElement.ParentUser).ParentUser).ParentUser).set_Name(((($sourceElement.ParentUser).ParentUser).ParentUser).Name);.Call ((($targetElement.ParentUser).ParentUser).ParentUser).set_Int32(((($sourceElement.ParentUser).ParentUser).ParentUser).Int32);.Call ((($targetElement.ParentUser).ParentUser).ParentUser).set_Int32Nullable(((($sourceElement.ParentUser).ParentUser).ParentUser).Int32Nullable);.Call ((($targetElement.ParentUser).ParentUser).ParentUser).set_Int32_Nullable(((($sourceElement.ParentUser).ParentUser).ParentUser).Int32_Nullable);.Call ((($targetElement.ParentUser).ParentUser).ParentUser).set_Int32NullableToInt32(((($sourceElement.ParentUser).ParentUser).ParentUser).Int32NullableToInt32);.Call ((($targetElement.ParentUser).ParentUser).ParentUser).set_DateTime(((($sourceElement.ParentUser).ParentUser).ParentUser).DateTime);.Call ((($targetElement.ParentUser).ParentUser).ParentUser).set_DateTimeNullable(((($sourceElement.ParentUser).ParentUser).ParentUser).DateTimeNullable);.Call ((($targetElement.ParentUser).ParentUser).ParentUser).set_Decimal(((($sourceElement.ParentUser).ParentUser).ParentUser).Decimal);.Call ((($targetElement.ParentUser).ParentUser).ParentUser).set_DecimalNullable(((($sourceElement.ParentUser).ParentUser).ParentUser).DecimalNullable);.Call ((($targetElement.ParentUser).ParentUser).ParentUser).set_DayOfWeek(((($sourceElement.ParentUser).ParentUser).ParentUser).DayOfWeek);.Call ((($targetElement.ParentUser).ParentUser).ParentUser).set_DayOfWeekNullable(((($sourceElement.ParentUser).ParentUser).ParentUser).DayOfWeekNullable);.Call ((($targetElement.ParentUser).ParentUser).ParentUser).set_Guid(((($sourceElement.ParentUser).ParentUser).ParentUser).Guid);.Call ((($targetElement.ParentUser).ParentUser).ParentUser).set_GuidNullable(((($sourceElement.ParentUser).ParentUser).ParentUser).GuidNullable);.If (((($sourceElement.ParentUser).ParentUser).ParentUser).MapPoint == null) {.Call ((($targetElement.ParentUser).ParentUser).ParentUser).set_MapPoint(.Default(HigLabo.Mapper.Test.MapPoint))} .Else {.Block() {.If (((($targetElement.ParentUser).ParentUser).ParentUser).MapPoint == null) {((($targetElement.ParentUser).ParentUser).ParentUser).MapPoint = .New HigLabo.Mapper.Test.MapPoint()} .Else {.Default(System.Void)};.Call (((($targetElement.ParentUser).ParentUser).ParentUser).MapPoint).set_Longitude((((($sourceElement.ParentUser).ParentUser).ParentUser).MapPoint).Longitude);.Call (((($targetElement.ParentUser).ParentUser).ParentUser).MapPoint).set_Latitude((((($sourceElement.ParentUser).ParentUser).ParentUser).MapPoint).Latitude)}};.Call ((($targetElement.ParentUser).ParentUser).ParentUser).set_VectorToNullable(((($sourceElement.ParentUser).ParentUser).ParentUser).VectorToNullable);.Call ((($targetElement.ParentUser).ParentUser).ParentUser).set_Vector2(((($sourceElement.ParentUser).ParentUser).ParentUser).Vector2);.If (((($sourceElement.ParentUser).ParentUser).ParentUser).ParentUser == null) {.Call ((($targetElement.ParentUser).ParentUser).ParentUser).set_ParentUser(.Default(HigLabo.Mapper.Test.User))} .Else {.Block() {.If (((($targetElement.ParentUser).ParentUser).ParentUser).ParentUser == null) {((($targetElement.ParentUser).ParentUser).ParentUser).ParentUser = .New HigLabo.Mapper.Test.User()} .Else {.Default(System.Void)};.Call (((($targetElement.ParentUser).ParentUser).ParentUser).ParentUser).set_Value((((($sourceElement.ParentUser).ParentUser).ParentUser).ParentUser).Value);.Call (((($targetElement.ParentUser).ParentUser).ParentUser).ParentUser).set_Name((((($sourceElement.ParentUser).ParentUser).ParentUser).ParentUser).Name);.Call (((($targetElement.ParentUser).ParentUser).ParentUser).ParentUser).set_Int32((((($sourceElement.ParentUser).ParentUser).ParentUser).ParentUser).Int32);.Call (((($targetElement.ParentUser).ParentUser).ParentUser).ParentUser).set_Int32Nullable((((($sourceElement.ParentUser).ParentUser).ParentUser).ParentUser).Int32Nullable);.Call (((($targetElement.ParentUser).ParentUser).ParentUser).ParentUser).set_Int32_Nullable((((($sourceElement.ParentUser).ParentUser).ParentUser).ParentUser).Int32_Nullable);.Call (((($targetElement.ParentUser).ParentUser).ParentUser).ParentUser).set_Int32NullableToInt32((((($sourceElement.ParentUser).ParentUser).ParentUser).ParentUser).Int32NullableToInt32);.Call (((($targetElement.ParentUser).ParentUser).ParentUser).ParentUser).set_DateTime((((($sourceElement.ParentUser).ParentUser).ParentUser).ParentUser).DateTime);.Call (((($targetElement.ParentUser).ParentUser).ParentUser).ParentUser).set_DateTimeNullable((((($sourceElement.ParentUser).ParentUser).ParentUser).ParentUser).DateTimeNullable);.Call (((($targetElement.ParentUser).ParentUser).ParentUser).ParentUser).set_Decimal((((($sourceElement.ParentUser).ParentUser).ParentUser).ParentUser).Decimal);.Call (((($targetElement.ParentUser).ParentUser).ParentUser).ParentUser).set_DecimalNullable((((($sourceElement.ParentUser).ParentUser).ParentUser).ParentUser).DecimalNullable);.Call (((($targetElement.ParentUser).ParentUser).ParentUser).ParentUser).set_DayOfWeek((((($sourceElement.ParentUser).ParentUser).ParentUser).ParentUser).DayOfWeek);.Call (((($targetElement.ParentUser).ParentUser).ParentUser).ParentUser).set_DayOfWeekNullable((((($sourceElement.ParentUser).ParentUser).ParentUser).ParentUser).DayOfWeekNullable);.Call (((($targetElement.ParentUser).ParentUser).ParentUser).ParentUser).set_Guid((((($sourceElement.ParentUser).ParentUser).ParentUser).ParentUser).Guid);.Call (((($targetElement.ParentUser).ParentUser).ParentUser).ParentUser).set_GuidNullable((((($sourceElement.ParentUser).ParentUser).ParentUser).ParentUser).GuidNullable);.If ((((($sourceElement.ParentUser).ParentUser).ParentUser).ParentUser).MapPoint == null) {.Call (((($targetElement.ParentUser).ParentUser).ParentUser).ParentUser).set_MapPoint(.Default(HigLabo.Mapper.Test.MapPoint))} .Else {.Block() {.If ((((($targetElement.ParentUser).ParentUser).ParentUser).ParentUser).MapPoint == null) {(((($targetElement.ParentUser).ParentUser).ParentUser).ParentUser).MapPoint = .New HigLabo.Mapper.Test.MapPoint()} .Else {.Default(System.Void)}}};.Call (((($targetElement.ParentUser).ParentUser).ParentUser).ParentUser).set_VectorToNullable((((($sourceElement.ParentUser).ParentUser).ParentUser).ParentUser).VectorToNullable);.Call (((($targetElement.ParentUser).ParentUser).ParentUser).ParentUser).set_Vector2((((($sourceElement.ParentUser).ParentUser).ParentUser).ParentUser).Vector2);.If ((((($sourceElement.ParentUser).ParentUser).ParentUser).ParentUser).ParentUser == null) {.Call (((($targetElement.ParentUser).ParentUser).ParentUser).ParentUser).set_ParentUser(.Default(HigLabo.Mapper.Test.User))} .Else {.Block() {.If ((((($targetElement.ParentUser).ParentUser).ParentUser).ParentUser).ParentUser == null) {(((($targetElement.ParentUser).ParentUser).ParentUser).ParentUser).ParentUser = .New HigLabo.Mapper.Test.User()} .Else {.Default(System.Void)}}};.If ((((($sourceElement.ParentUser).ParentUser).ParentUser).ParentUser).Dictionary == null) {.Call (((($targetElement.ParentUser).ParentUser).ParentUser).ParentUser).set_Dictionary(.Default(System.Collections.Generic.Dictionary`2[System.String,System.String]))} .Else {.Block() {.If ((((($targetElement.ParentUser).ParentUser).ParentUser).ParentUser).Dictionary == null) {(((($targetElement.ParentUser).ParentUser).ParentUser).ParentUser).Dictionary = .New System.Collections.Generic.Dictionary`2[System.String,System.String]()} .Else {.Default(System.Void)}}}}};.If (((($sourceElement.ParentUser).ParentUser).ParentUser).Dictionary == null) {.Call ((($targetElement.ParentUser).ParentUser).ParentUser).set_Dictionary(.Default(System.Collections.Generic.Dictionary`2[System.String,System.String]))} .Else {.Block() {.If (((($targetElement.ParentUser).ParentUser).ParentUser).Dictionary == null) {((($targetElement.ParentUser).ParentUser).ParentUser).Dictionary = .New System.Collections.Generic.Dictionary`2[System.String,System.String]()} .Else {.Default(System.Void)}}}}};.If ((($sourceElement.ParentUser).ParentUser).Dictionary == null) {.Call (($targetElement.ParentUser).ParentUser).set_Dictionary(.Default(System.Collections.Generic.Dictionary`2[System.String,System.String]))} .Else {.Block() {.If ((($targetElement.ParentUser).ParentUser).Dictionary == null) {(($targetElement.ParentUser).ParentUser).Dictionary = .New System.Collections.Generic.Dictionary`2[System.String,System.String]()} .Else {.Default(System.Void)}}}}};.If (($sourceElement.ParentUser).Dictionary == null) {.Call ($targetElement.ParentUser).set_Dictionary(.Default(System.Collections.Generic.Dictionary`2[System.String,System.String]))} .Else {.Block() {.If (($targetElement.ParentUser).Dictionary == null) {($targetElement.ParentUser).Dictionary = .New System.Collections.Generic.Dictionary`2[System.String,System.String]()} .Else {.Default(System.Void)}}}}};.If ($sourceElement.Dictionary == null) {.Call $targetElement.set_Dictionary(.Default(System.Collections.Generic.Dictionary`2[System.String,System.String]))} .Else {.Block() {.If ($targetElement.Dictionary == null) {$targetElement.Dictionary = .New System.Collections.Generic.Dictionary`2[System.String,System.String]()} .Else {.Default(System.Void)}}};.Call ($target.Users).Add($targetElement);$i += 1}}.LabelTarget endLoop:;.Label.LabelTarget end:};.Block(System.Guid $sourceElement,System.Guid $targetElement,System.Int32 $i) {$i;.If ($source.GuidList == null) {.Return end { }} .Else {.Default(System.Void)};$i = 0;.Loop  {.Block() {.If (($source.GuidList).Count <= $i) {.Break endLoop { }} .Else {.Default(System.Void)};$sourceElement = ($source.GuidList).Item[$i];$targetElement = (System.Guid)$sourceElement;.Call ($target.GuidList).Add($targetElement);$i += 1}}.LabelTarget endLoop:;.Label.LabelTarget end:};.If ($source.Tags != null) {.Block(System.String $sourceElement,System.String $targetElement,System.Int32 $i,System.String[] $arrayMember) {$i;$i = 0;$arrayMember;$arrayMember = .NewArray System.String[($source.Tags).Length];.Loop  {.Block() {.If (($source.Tags).Length <= $i) {.Break endLoop { }} .Else {.Default(System.Void)};$sourceElement = ($source.Tags)[$i];$targetElement = $sourceElement;$arrayMember[$i] = $targetElement;$i += 1}}.LabelTarget endLoop:;$target.Tags = $arrayMember}} .Else {.Default(System.Void)};.If ($source.Timestamp != null) {.Block(System.Byte $sourceElement,System.Byte $targetElement,System.Int32 $i,System.Byte[] $arrayMember) {$i;$i = 0;$arrayMember;$arrayMember = .NewArray System.Byte[($source.Timestamp).Length];.Loop  {.Block() {.If (($source.Timestamp).Length <= $i) {.Break endLoop { }} .Else {.Default(System.Void)};$sourceElement = ($source.Timestamp)[$i];$targetElement = $sourceElement;$arrayMember[$i] = $targetElement;$i += 1}}.LabelTarget endLoop:;$target.Timestamp = $arrayMember}} .Else {.Default(System.Void)};$target}
}

这些块将编译为Func<TSource, TTarget, MapContext, TTarget>的lambda func 并保存private _MapActionList字段。当然,此编译过程仅在第一次时使用一次,然后重新使用保存_MapActionList代码的Func。AddPostAction会将其Func与您的Lambda 结合起来,ReplaceMap将其替换Func。

HigLabo.Mapper,用表达式树在10天内创建世界上最快的对象映射器相关推荐

  1. yandex浏览器_您可以在10分钟内创建自己的任务管理器:Yandex的实践

    yandex浏览器 那里有许多任务管理应用程序,但是制作自己的应用程序总是令人兴奋的. 在本演练中,我将向您展示如何编写一个可在浏览器中运行的简单任务管理应用程序. 在以后的情节中,我将向您展示如何升 ...

  2. C#复习笔记(4)--C#3:革新写代码的方式(Lambda表达式和表达式树)

    Lambda表达式和表达式树 先放一张委托转换的进化图 看一看到lambda简化了委托的使用. lambda可以隐式的转换成委托或者表达式树.转换成委托的话如下面的代码: Func<string ...

  3. 为给定的Lambda表达式构建表达式树

    这是用于将给定的LINQ表达式转换为对应的表达式树的代码示例. //using LINQAlias = System.Linq.Expressions; List<Host> dinner ...

  4. 表达式树练习实践:入门基础

    什么是表达式树 来自微软官方文档的定义: 表达式树以树形数据结构表示代码. 它能干什么呢? 你可以对表达式树中的代码进行编辑和运算.这样能够动态修改可执行代码.在不同数据库中执行 LINQ 查询以及创 ...

  5. asp.net core 排序过滤分页组件:sieve(2)表达式树的复习

    在Sieve组件中使用了很多关于表达式树的知识,但在我们日常的工作中写表达式树的机会是非常少的,至少在我的编程生涯中没怎么写过表达式树(可能也就是3,4次).所以,为了能够看懂Sieve里面的源代码, ...

  6. 程序猿修仙之路--数据结构之你是否真的懂数组? c#socket TCP同步网络通信 用lambda表达式树替代反射 ASP.NET MVC如何做一个简单的非法登录拦截...

    程序猿修仙之路--数据结构之你是否真的懂数组? 数据结构 但凡IT江湖侠士,算法与数据结构为必修之课.早有前辈已经明确指出:程序=算法+数据结构  .要想在之后的江湖历练中通关,数据结构必不可少.数据 ...

  7. 表达式树 php,Linux_LINQ学习笔记:表达式树,构建查询表达式 本节中, 我们 - phpStudy...

    构建查询表达式 本节中, 我们假设我们拥有一个这样的实体类: 1: [Table] public partial class Product 2: 3: { 4: 5: [Column(IsPrima ...

  8. IEnumerable和IQueryable的区别以及背后的ExpressionTree表达式树

    关于IEnumerable和IQueryable的区别,这事还要从泛型委托Func<T>说起.来看一个简单的泛型委托例子: class Program { static void Main ...

  9. C# Lambda表达式详解,及Lambda表达式树的创建

    每次写博客,第一句话都是这样的:程序员很苦逼,除了会写程序,还得会写博客!当然,希望将来的一天,某位老板看到此博客,给你的程序员职工加点薪资吧!因为程序员的世界除了苦逼就是沉默.我眼中的程序员大多都不 ...

最新文章

  1. Shiny平台构建与R包开发(二)——数据输入
  2. 快速原型工具 原型可视化
  3. 零基础学python需要多久-零基础学Python要多久
  4. 多台Linux服务器SSH相互访问无需密码--转
  5. myBatis异常提示For input string: {1=null}
  6. 服务器虚拟化的意思,服务器虚拟化存储的好处以及作用
  7. 自定义beans.xml文件实现Spring框架
  8. LeetCode 11盛水最多的容器
  9. 基于java的邮件服务器以及webmail的搭建
  10. 商务英语中最易犯的五个错误
  11. 微软官方硬盘备份软件SyncToy
  12. Linux——(渗透理解)文件系统与日志分析
  13. 响应式网页设计_响应式网页设计中的常用技术
  14. python的全局静态变量
  15. 2017年中国大数据发展趋势和展望解读(下)
  16. 【两周快速入门pr】一、电子相册案例——快速带你走进剪辑的世界
  17. 人类一败涂地做图教程_人类一败涂地怎么捏人?自定义人物PS制作教程
  18. SQL Server无法连接到本地数据库
  19. HihoCoder 1245:王胖浩与三角形 三角形边长与面积
  20. 如何安装husky_统一用户认证平台(Husky)说明文档

热门文章

  1. c语言中结构体头文件是什么,函数形参里有结构体指针,为什么在头文件生
  2. C语言指针实数组输入输出,C语言:回来两个数组中第一个元素的指针,并输出这个值...
  3. 硬盘损坏如何恢oracle,硬盘物理损坏,如何恢复数据库?
  4. 设计灵感|纯文字排版也能让海报引人注目
  5. 圣诞节海报设计需要的手写字体素材
  6. APP时间界面设计模板,可临摹学习的好素材
  7. 设计师值得拥有的设计导航
  8. c语言中如何让鼠标在一个窗口之外不能点击_Excel系列教程:如何自动填充单元格...
  9. python实现发送免费短信功能
  10. Fedora CoreOS to CentOS7 问题汇总1