/// <summary> /// </summary> /// <param name="field"></param> /// <returns></returns> internal static TmphMemberInfo GetSerialize(TmphFieldIndex field) { var member = new TmphMemberInfo(field); var type = field.Member.FieldType; if (type.IsEnum) TmphDataSerialize.FixedSizes.TryGetValue(type.GetEnumUnderlyingType(), out member.SerializeFixedSize); else if (type.IsValueType) { var nullType = type.nullableType(); if (nullType == null) { TmphDataSerialize.FixedSizes.TryGetValue(type, out member.SerializeFixedSize); if (type == typeof(bool)) member.NullMapSize = 1; } else { member.NullMapSize = type == typeof(bool?) ? (byte)2 : (byte)1; TmphDataSerialize.FixedSizes.TryGetValue(nullType, out member.SerializeFixedSize); } } else member.NullMapSize = 1; return member; }
/// <summary> /// 字段信息 /// </summary> /// <param name="field"></param> /// <param name="attribute"></param> public TmphFieldInfo(TmphFieldIndex field, TmphDataMember attribute) { Field = field.Member; DataMember = attribute; MemberMapIndex = field.MemberIndex; }