提交 dfcebe2f 编写于 作者: T tanghai

修复客户端mongo bson库找不到DynamicMethod方法的错误

上级 2edb71b0
......@@ -48,3 +48,4 @@ Server/.DS_Store
.vs/
.objs/
/Unity/.gradle
/*.user
......@@ -580,18 +580,7 @@ namespace MongoDB.Bson.Serialization
throw new BsonSerializationException(message);
}
var sourceType = fieldInfo.DeclaringType;
var method = new DynamicMethod("Set" + fieldInfo.Name, null, new[] { typeof(object), typeof(object) }, true);
var gen = method.GetILGenerator();
gen.Emit(OpCodes.Ldarg_0);
gen.Emit(OpCodes.Castclass, sourceType);
gen.Emit(OpCodes.Ldarg_1);
gen.Emit(OpCodes.Unbox_Any, fieldInfo.FieldType);
gen.Emit(OpCodes.Stfld, fieldInfo);
gen.Emit(OpCodes.Ret);
return (Action<object, object>)method.CreateDelegate(typeof(Action<object, object>));
return (obj, value) => { fieldInfo.SetValue(obj, value); };
}
private Func<object, object> GetGetter()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册