public PropertyData(PropertyInfo propertyInfo, TypeStorage storage, bool builder = false) { PropertyInfo = propertyInfo; BinaryAttr = propertyInfo.GetCustomAttribute <BinaryAttribute>(); BinarySchemeAttrList = propertyInfo.GetCustomAttributes <BinarySchemeAttribute>().ToList(); if (builder == false) { IsBaseType = typeof(IBasicType).IsAssignableFrom(BinaryAttr.Type); //if (PropertyInfo.Name == "CharacterPart") // Debugger.Break(); if (IsBaseType) { BinaryType = (IBasicType)Activator.CreateInstance(BinaryAttr.Type); } //else // BinaryStruct = storage.GetTypeInfo(BinaryAttr.Type,""); } Getter = propertyInfo.GetMethod; Setter = propertyInfo.SetMethod; }
public BinaryStruct(Type type, string scheme, List <PropertyData> propertyList, Encoding coding, TypeStorage currentStorage, bool builderCompile = false) { Type = type; Scheme = scheme; Coding = coding; CurrentStorage = currentStorage; if (string.IsNullOrEmpty(scheme)) { var existOldType = builderCompile? currentStorage.GetTypeInfo(type, "") : null; if (existOldType == null) { PropertyList = propertyList; } else { PropertyList = FillPropertyes(existOldType, propertyList); } PropertyList = PropertyList.OrderBy(x => x.PropertyInfo.Name).ToList(); } else { PropertyList = propertyList.Where(x => x.BinarySchemeAttrList.FirstOrDefault(y => y.SchemeName == scheme) != null).Select(y => new PropertyData(y, scheme, CurrentStorage)).ToList(); foreach (var item in PropertyList) { if (!item.IsBaseType) { item.BinaryStruct = item.BinaryStruct.GetSchemeData(scheme, Coding, CurrentStorage); } } } }
public BinaryStruct GetSchemeData(string schemeName, Encoding coding, TypeStorage currentStorage) { var s = new BinaryStruct(Type, schemeName, PropertyList, coding, currentStorage); s.Compile(); return(s); }
public PropertyData(PropertyData propertyData, string scheme, TypeStorage storage) { PropertyInfo = propertyData.PropertyInfo; BinaryAttr = propertyData.BinaryAttr; BinarySchemeAttrList = propertyData.BinarySchemeAttrList; IsBaseType = typeof(IBasicType).IsAssignableFrom(BinaryAttr.Type); if (IsBaseType) { BinaryType = (IBasicType)Activator.CreateInstance(BinaryAttr.Type); } else { BinaryStruct = storage.GetTypeInfo(BinaryAttr.Type, scheme); } Getter = propertyData.PropertyInfo.GetMethod; Setter = propertyData.PropertyInfo.SetMethod; }
public BinarySerializer(TypeStorage typeStorage) { storage = typeStorage; }