private void EmitConvertItem(TypeBuilder typeBuilder, TypePair typePair, string methodName = ConvertItemMethod) { MapperCacheItem mapperCacheItem = CreateMapperCacheItem(typePair); MethodBuilder methodBuilder = typeBuilder.DefineMethod(methodName, OverrideProtected, typeof(object), new[] { typeof(object) }); IEmitterType sourceMemeber = EmitArgument.Load(typeof(object), 1); IEmitterType targetMember = EmitNull.Load(); IEmitterType callMapMethod = mapperCacheItem.EmitMapMethod(sourceMemeber, targetMember); EmitReturn.Return(callMapMethod).Emit(new CodeGenerator(methodBuilder.GetILGenerator())); }
private static IEmitterType EmitRefType(Type type) { return(type.HasDefaultCtor() ? EmitNewObj.NewObj(type) : EmitNull.Load()); }