提交 8537bf99 编写于 作者: 若汝棋茗

修复matedata序列化bug

上级 14202979
......@@ -14,7 +14,7 @@ namespace TouchSocket.Core
/// <summary>
/// 动态成员访问器
/// </summary>
public MemberAccessor():base(typeof(T))
public MemberAccessor() : base(typeof(T))
{
}
......@@ -23,11 +23,11 @@ namespace TouchSocket.Core
/// <summary>
/// 动态成员访问器
/// </summary>
public class MemberAccessor: IMemberAccessor
public class MemberAccessor : IMemberAccessor
{
Func<object, string, object> GetValueDelegate;
Func<object, string, object> GetValueDelegate;
Action<object, string, object> SetValueDelegate;
Action<object, string, object> SetValueDelegate;
/// <summary>
/// 动态成员访问器
......@@ -52,7 +52,7 @@ namespace TouchSocket.Core
/// <summary>
/// 获取属性
/// </summary>
public Func<Type, PropertyInfo[]>OnGetProperties { get; set; }
public Func<Type, PropertyInfo[]> OnGetProperties { get; set; }
/// <summary>
/// 获取字段
......@@ -97,6 +97,10 @@ namespace TouchSocket.Core
cases.Add(Expression.SwitchCase(Expression.Convert(property, typeof(object)), propertyHash));
}
if (cases.Count == 0)
{
return (a, b) => default;
}
var switchEx = Expression.Switch(nameHash, Expression.Constant(null), cases.ToArray());
var methodBody = Expression.Block(typeof(object), new[] { nameHash }, calHash, switchEx);
......@@ -131,6 +135,10 @@ namespace TouchSocket.Core
cases.Add(Expression.SwitchCase(Expression.Convert(setValue, typeof(object)), propertyHash));
}
if (cases.Count == 0)
{
return (a, b, c) => { };
}
var switchEx = Expression.Switch(nameHash, Expression.Constant(null), cases.ToArray());
var methodBody = Expression.Block(typeof(object), new[] { nameHash }, calHash, switchEx);
......
......@@ -4,7 +4,7 @@
<ApplicationIcon>logo.ico</ApplicationIcon>
<SignAssembly>True</SignAssembly>
<AssemblyOriginatorKeyFile>D:\MyStore\13_Doc\Keys\TouchSocket.snk</AssemblyOriginatorKeyFile>
<Version>1.1.0</Version>
<Version>1.1.1</Version>
<LangVersion>8.0</LangVersion>
<Company>若汝棋茗</Company>
<Copyright>Copyright © 2022 若汝棋茗</Copyright>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册