public T Deserialize <T>(string scheme, byte[] buffer, ref int offset) { var type = storage.GetTypeInfo(typeof(T), scheme); var result = type.ReadMethod(buffer, type, offset); offset = result.Item1; return((T)result.Item2); }
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 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; }