示例#1
0
        public IEmitterType EmitMapMethod(IEmitterType sourceMemeber, IEmitterType targetMember)
        {
            Type         mapperType   = typeof(Mapper);
            MethodInfo   mapMethod    = mapperType.GetMethod(Mapper.MapMethodName, BindingFlags.Instance | BindingFlags.Public);
            FieldInfo    mappersField = mapperType.GetField(Mapper.MappersFieldName, BindingFlags.Instance | BindingFlags.NonPublic);
            IEmitterType mappers      = EmitField.Load(EmitThis.Load(mapperType), mappersField);
            IEmitterType mapper       = EmitArray.Load(mappers, Id);
            IEmitterType result       = EmitMethod.Call(mapMethod, mapper, sourceMemeber, targetMember);

            return(result);
        }
        public IEmitterType EmitMapMethod(IEmitterType sourceMember, IEmitterType targetMember)
        {
            var mapperType   = typeof(Mapper);
            var mapMethod    = mapperType.GetMethod(Mapper.MAP_METHOD_NAME, BindingFlags.Instance | BindingFlags.Public);
            var mappersField = mapperType.GetField(Mapper.MAPPERS_FIELD_NAME, BindingFlags.Instance | BindingFlags.NonPublic);
            var mappers      = EmitField.Load(EmitThis.Load(mapperType), mappersField);
            var mapper       = EmitArray.Load(mappers, Id);
            var result       = EmitMethod.Call(mapMethod, mapper, sourceMember, targetMember);

            return(result);
        }