提交 4ac00d5e 编写于 作者: T tanghai

去掉AOT宏,UNITY_IOS宏替代

上级 83cc0b00
......@@ -1277,9 +1277,9 @@ namespace MongoDB.Bson.Serialization
ConstructorInfo defaultConstructor = classTypeInfo.GetConstructors(bindingFlags)
.Where(c => c.GetParameters().Length == 0)
.SingleOrDefault();
#if AOT
#if UNITY_IOS
_creator = () => defaultConstructor.Invoke(null);
#else
#else
if (defaultConstructor != null)
{
// lambdaExpression = () => (object) new TClass()
......@@ -1298,7 +1298,7 @@ namespace MongoDB.Bson.Serialization
var lambdaExpression = Expression.Lambda<Func<object>>(body);
_creator = lambdaExpression.Compile();
#endif
#endif
}
return _creator;
}
......
......@@ -16,7 +16,7 @@
using System;
using System.Linq.Expressions;
using System.Reflection;
#if !AOT
#if !UNITY_IOS
using System.Reflection.Emit;
#endif
using MongoDB.Bson.Serialization.Serializers;
......@@ -582,7 +582,7 @@ namespace MongoDB.Bson.Serialization
throw new BsonSerializationException(message);
}
#if AOT
#if UNITY_IOS
return (obj, value) => { fieldInfo.SetValue(obj, value); };
#else
var sourceType = fieldInfo.DeclaringType;
......@@ -602,7 +602,7 @@ namespace MongoDB.Bson.Serialization
private Func<object, object> GetGetter()
{
#if AOT
#if UNITY_IOS
PropertyInfo propertyInfo = _memberInfo as PropertyInfo;
if (propertyInfo != null)
{
......@@ -619,7 +619,7 @@ namespace MongoDB.Bson.Serialization
FieldInfo fieldInfo = _memberInfo as FieldInfo;
return (obj) => { return fieldInfo.GetValue(obj); };
#else
#else
var propertyInfo = _memberInfo as PropertyInfo;
if (propertyInfo != null)
{
......@@ -647,17 +647,17 @@ namespace MongoDB.Bson.Serialization
);
return lambdaExpression.Compile();
#endif
#endif
}
private Action<object, object> GetPropertySetter()
{
#if AOT
#if UNITY_IOS
var propertyInfo = (PropertyInfo) _memberInfo;
return (obj, value) => { propertyInfo.SetValue(obj, value); };
#else
#else
var propertyInfo = (PropertyInfo)_memberInfo;
var setMethodInfo = propertyInfo.SetMethod;
if (IsReadOnly)
......@@ -682,7 +682,7 @@ namespace MongoDB.Bson.Serialization
);
return lambdaExpression.Compile();
#endif
#endif
}
private void ThrowFrozenException()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册