12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
-
- using System;
- using System.Reflection;
- namespace Topten.JsonKit
- {
-
- class JsonMemberInfo
- {
- public JsonMemberInfo()
- {
- }
-
- public string JsonKey;
-
- public bool KeepInstance => Attribute?.KeepInstance ?? false;
-
- public bool Deprecated => Attribute?.Deprecated ?? false;
-
- public bool ExcludeIfNull => Attribute?.ExcludeIfNull ?? false;
-
- public bool ExcludeIfEmpty => Attribute?.ExcludeIfEmpty ?? false;
-
- public object ExcludeIfEquals => Attribute?.ExcludeIfEquals;
-
- public JsonAttribute Attribute
- {
- get;
- set;
- }
-
- MemberInfo _mi;
- public MemberInfo Member
- {
- get { return _mi; }
- set
- {
-
- _mi = value;
-
- if (_mi is PropertyInfo)
- {
- GetValue = (obj) => ((PropertyInfo)_mi).GetValue(obj, null);
- SetValue = (obj, val) => ((PropertyInfo)_mi).SetValue(obj, val, null);
- }
- else
- {
- GetValue = ((FieldInfo)_mi).GetValue;
- SetValue = ((FieldInfo)_mi).SetValue;
- }
- }
- }
-
- public Type MemberType
- {
- get
- {
- if (Member is PropertyInfo)
- {
- return ((PropertyInfo)Member).PropertyType;
- }
- else
- {
- return ((FieldInfo)Member).FieldType;
- }
- }
- }
-
- public Action<object, object> SetValue;
- public Func<object, object> GetValue;
- }
- }
|