public SerializationOptions(LengthPos LenPos, PointerType PtrType, bool ForceWriteStaticVersion = false) { this.LenPos = LenPos; this.PtrType = PtrType; this.ForceWriteStaticVersion = ForceWriteStaticVersion; }
private void WriteValue(RefValue Ref) { FieldInfo Info = Ref.Info; object Parent = Ref.Parent; object Value = Ref.Value; bool Range = Info?.IsDefined(typeof(RangeAttribute)) ?? false; LengthPos LenPos = GetLengthPos(Info); if (Value != null && (!(Value is IList) || ((IList)Value).Count > 0 || Range)) { ObjectInfo ObjInfo = GetObjInfo(Value, Info); long Position = BaseStream.Position; if (ObjInfo.Position == Position) { if (Parent != null && Parent is ICustomSerializeCmd && Info?.FieldType == typeof(uint[])) { ((ICustomSerializeCmd)Parent).SerializeCmd(this, Value); } AddObjInfo(Value, Position); WriteValue(Value); } if (Ref.Position != -1) { long EndPos = BaseStream.Position; BaseStream.Seek(Ref.Position, SeekOrigin.Begin); uint Pointer = ObjInfo.Position + Ref.PointerOffset; if (LenPos == LengthPos.AfterPtr) { WritePointer(Pointer); } if (Ref.HasLength) { if (Range) { WritePointer((uint)(ObjInfo.Length != 0 ? ObjInfo.Length : EndPos)); } else if (GetLengthSize(Info) == LengthSize.Short) { Writer.Write((ushort)((IList)Value).Count); } else { Writer.Write(((IList)Value).Count); } } if (LenPos == LengthPos.BeforePtr) { WritePointer(Pointer); } if (Ref.HasTwoPtr) { WritePointer(Pointer); } BaseStream.Seek(EndPos, SeekOrigin.Begin); } } }
public CustomLengthAttribute(LengthPos Pos, LengthSize Size) { this.Pos = Pos; this.Size = Size; }
public SerializationOptions(LengthPos LenPos, PointerType PtrType) { this.LenPos = LenPos; this.PtrType = PtrType; }