private MemberEmitterDescription EmitMappingMembers(TypePair typePair) { List <MappingMember> members = _mappingMemberBuilder.Build(typePair); MemberEmitterDescription result = _memberMapper.Build(typePair, members); return(result); }
public void Build_CommonFileds_Success() { var mappingMemberBuilder = new MappingMemberBuilder(new MappingBuilderConfigStub()); List <MappingMemberPath> members = mappingMemberBuilder.Build(new TypePair(typeof(SourceSimple), typeof(TargetSimple))); XAssert.Equal(2, members.Count); }
public void Buid_Recursion_Success() { var mappingMemberBuilder = new MappingMemberBuilder(new MappingBuilderConfigStub()); List <MappingMemberPath> members = mappingMemberBuilder.Build(new TypePair(typeof(SourceWithRecursion), typeof(TargetWithRecursion))); XAssert.Equal(2, members.Count); }
public void Build_IgnoreProperty_Success() { var bindingConfig = new BindingConfig(); bindingConfig.IgnoreSourceField(nameof(SourceWithRecursion.Id)); var mappingMemberBuilder = new MappingMemberBuilder(new MappingBuilderConfigStub(bindingConfig)); List <MappingMemberPath> members = mappingMemberBuilder.Build(new TypePair(typeof(SourceWithRecursion), typeof(TargetWithRecursion))); XAssert.Single(members); }
public void Build_IgnoreProperty_Success() { var bindingConfig = new BindingConfig(); bindingConfig.IgnoreField("Id"); var mappingMemberBuilder = new MappingMemberBuilder(new MappingBuilderConfigStub(bindingConfig)); List <MappingMember> members = mappingMemberBuilder.Build(new TypePair(typeof(Source1), typeof(Target1))); Assert.Equal(1, members.Count); }
private Option <MapperCache> EmitMapClass(TypePair typePair, TypeBuilder typeBuilder) { List <MappingMember> members = _mappingMemberBuilder.Build(typePair); MethodBuilder methodBuilder = typeBuilder.DefineMethod(MapClassMethod, OverrideProtected, typePair.Target, new[] { typePair.Source, typePair.Target }); var codeGenerator = new CodeGenerator(methodBuilder.GetILGenerator()); var emitterComposite = new EmitComposite(); MemberEmitterDescription emitterDescription = EmitMappingMembers(members); emitterComposite.Add(emitterDescription.Emitter); emitterComposite.Add(EmitReturn.Return(EmitArgument.Load(typePair.Target, 2))); emitterComposite.Emit(codeGenerator); return(emitterDescription.MapperCache); }