public static IMapDataSource <TKey, TValue> Deserialize <TKey, TValue>(ref BssomReader reader, ref BssomDeserializeContext context) { byte type = reader.SkipBlankCharacterAndReadBssomType(); if (type == BssomType.NullCode) { return(default);
public Version Deserialize(ref BssomReader reader, ref BssomDeserializeContext context) { string val = reader.ReadString(); if (val == null) { return(default);
public static BssomNumber DeserializePrimitiveWithBssomPrimitiveType(ref BssomReader reader) { byte ct = reader.SkipBlankCharacterAndReadBssomType(); switch (ct) { case BssomType.Int32Code: return(new BssomNumber(reader.ReadInt32WithOutTypeHead())); case BssomType.Int16Code: return(new BssomNumber(reader.ReadInt16WithOutTypeHead())); case BssomType.Int64Code: return(new BssomNumber(reader.ReadInt64WithOutTypeHead())); case BssomType.UInt64Code: return(new BssomNumber(reader.ReadUInt64WithOutTypeHead())); case BssomType.UInt32Code: return(new BssomNumber(reader.ReadUInt32WithOutTypeHead())); case BssomType.UInt16Code: return(new BssomNumber(reader.ReadUInt16WithOutTypeHead())); case BssomType.UInt8Code: return(new BssomNumber(reader.ReadUInt8WithOutTypeHead())); default: //case BssomType.Int8Code: return(new BssomNumber(reader.ReadInt8WithOutTypeHead())); } }
public Guid ReadElement(ref BssomReader reader, BssomSerializerOptions option, BssomFieldOffsetInfo offsetInfo) { if (offsetInfo.Array1ElementTypeIsNativeType == true && offsetInfo.Array1ElementType == NativeBssomType.GuidCode) { return(reader.ReadGuidWithOutTypeHead()); } return(BssomSerializationArgumentException.InvalidOffsetInfoFormat <Guid>()); }
public BssomNumber Deserialize(ref BssomReader reader, ref BssomDeserializeContext context) { if (reader.TryReadNull()) { return(null); } return(BssomObjectFormatterHelper.DeserializePrimitiveWithBssomPrimitiveType(ref reader)); }
public static BssMapHeadPackInfo Create(ref BssomReader reader) { BssMapHeadPackInfo pars = new BssMapHeadPackInfo(); pars.ReadPosition = reader.Position; pars.MapHead = BssMapHead.Read(ref reader); pars.MapRouteDataStartPos = reader.Position; return(pars); }
public Int32 ReadElement(ref BssomReader reader, BssomSerializerOptions option, BssomFieldOffsetInfo offsetInfo) { if (offsetInfo.Array1ElementTypeIsNativeType == false && offsetInfo.Array1ElementType == BssomType.Int32Code) { return(reader.ReadInt32WithOutTypeHead()); } return(BssomSerializationArgumentException.InvalidOffsetInfoFormat <Int32>()); }
public static BssMapHead Read(ref BssomReader reader) { BssMapHead header = new BssMapHead(); header.DataLength = reader.ReadVariableNumber(); header.ElementCount = reader.ReadVariableNumber(); header.MaxDepth = reader.ReadVariableNumber(); header.RouteLength = reader.ReadVariableNumber(); return(header); }
private void AssertSchema(string schemaString, params string[] keys) { var buf = BssomSerializer.Serialize(GenerateDict(keys), BssomSerializerOptions.Default.WithIDictionaryIsSerializeMap1Type(false)); var reader = new BssomReader(new SimpleBufferWriter(buf)); reader.EnsureType(BssomType.Map2); string ss = BssMapObjMarshal.GetSchemaString(ref reader); Assert.Equal(schemaString, ss); }
public unsafe string Deserialize(ref BssomReader reader, ref BssomDeserializeContext context) { if (reader.TryReadNull()) { return(null); } reader.EnsureType(BssomType.StringCode); int dataLen = reader.ReadVariableNumber(); ref byte refb = ref reader.BssomBuffer.ReadRef((int)dataLen);
public BssomGuid Deserialize(ref BssomReader reader, ref BssomDeserializeContext context) { object val = BssomObjectFormatterHelper.DeserializeBssObject(ref reader, ref context, true); if (val == null) { return(null); } return((BssomGuid)val); }
public static BssMapObjMarshalReader <TKey, TValue> Create(ref BssomReader reader, ref BssomDeserializeContext context, bool isOnlyReadFieldOffset = false) { BssMapObjMarshalReader <TKey, TValue> apr = new BssMapObjMarshalReader <TKey, TValue>(); apr._reader = reader; apr._context = context; apr.Paras = BssMapHeadPackInfo.Create(ref reader); if (!isOnlyReadFieldOffset) { apr.ValueFormatter = context.Option.FormatterResolver.GetFormatterWithVerify <TValue>(); } return(apr); }
public DateTime ReadElement(ref BssomReader reader, BssomSerializerOptions option, BssomFieldOffsetInfo offsetInfo) { if (offsetInfo.Array1ElementTypeIsNativeType == false && offsetInfo.Array1ElementType == BssomType.TimestampCode) { return(reader.ReadStandDateTimeWithOutTypeHead()); } else if (offsetInfo.Array1ElementTypeIsNativeType == true && offsetInfo.Array1ElementType == NativeBssomType.DateTimeCode) { return(reader.ReadNativeDateTimeWithOutTypeHead()); } else { return(BssomSerializationArgumentException.InvalidOffsetInfoFormat <DateTime>()); } }
public static void VerifySize(object value, BssomSerializerOptions option = null) { var buf = BssomSerializer.Serialize(value, option); buf.Length.Is(BssomSerializer.Size(value, option)); var reader = new BssomReader(new SimpleBufferWriter(buf)); reader.SkipObject(); reader.Position.Is(buf.Length); var bsfm = new BssomFieldMarshaller(buf); bsfm.ReadValueSize(BssomFieldOffsetInfo.Zero).Is(buf.Length); }
public Map1DataSource(BssomReader reader, BssomDeserializeContext context, bool isOnlyReadFieldOffset = false) { _reader = reader; _context = context; KeyFormatter = context.Option.FormatterResolver.GetFormatterWithVerify <TKey>(); if (!isOnlyReadFieldOffset) { ValueFormatter = context.Option.FormatterResolver.GetFormatterWithVerify <TValue>(); } ReadPosition = reader.Position; int size = reader.ReadVariableNumber(); EndPosition = reader.Position + size; Count = reader.ReadVariableNumber(); }
public T[] Deserialize(ref BssomReader reader, ref BssomDeserializeContext context) { if (reader.TryReadNullWithEnsureBuildInType(BssomType.Array2)) { return(default);
public static void IsArray2(this byte[] bytes) { var reader = new BssomReader(new SimpleBufferWriter(bytes)); reader.ReadBssomType().Is(BssomType.Array2); }
BssomDecimal IArray1ElementWriter <BssomDecimal> .ReadElement(ref BssomReader reader, BssomSerializerOptions option, BssomFieldOffsetInfo offsetInfo) { return((BssomDecimal)BssomValue.Create(ReadElement(ref reader, option, offsetInfo))); }
public object ReadObjectElement(ref BssomReader reader, BssomSerializerOptions option, BssomFieldOffsetInfo offsetInfo) { throw new NotImplementedException(); }
public Object ReadElement(ref BssomReader reader, BssomSerializerOptions option, BssomFieldOffsetInfo offsetInfo) { IArray1ElementWriter array1ElementWriter = Array1ElementWriterContainers.GetArray1ElementWriter(offsetInfo.Array1ElementTypeIsNativeType, offsetInfo.Array1ElementType); return(array1ElementWriter.ReadObjectElement(ref reader, option, offsetInfo)); }
public object Deserialize(ref BssomReader reader, ref BssomDeserializeContext context) { return(BssomObjectFormatterHelper.DeserializeBssObject(ref reader, ref context, context.Option.IsPriorityToDeserializeObjectAsBssomValue)); }
public SByte[] Deserialize(ref BssomReader reader, ref BssomDeserializeContext context) { if (reader.TryReadNullWithEnsureArray1BuildInType(BssomType.Int8Code)) { return(default);
public object ReadObjectElement(ref BssomReader reader, BssomSerializerOptions option, BssomFieldOffsetInfo offsetInfo) { return(ReadElement(ref reader, option, offsetInfo)); }
public Guid Deserialize(ref BssomReader reader, ref BssomDeserializeContext context) { return(reader.ReadGuid()); }
public T Deserialize(ref BssomReader reader, ref BssomDeserializeContext context) { return(deserializer(ref reader, ref context)); }
public int Deserialize(ref BssomReader reader, ref BssomDeserializeContext context) { return(PrimitiveResolver.Instance.GetFormatter <int>().Deserialize(ref reader, ref context) + 1); }
public static unsafe string GetSchemaString(ref BssomReader reader) { long positionWithOutMap2TypeHead(ref BssomReader r) { return(r.Position - 1); } MapSchemaStringBuilder msb = new MapSchemaStringBuilder(); BssMapHead head = BssMapHead.Read(ref reader); byte nextKeyByteCount = 0; BssMapRouteToken t = default; int count = head.ElementCount; BssmapAnalysisStack stack = new BssmapAnalysisStack(head.MaxDepth); AutomateState state = AutomateState.ReadBranch; switch (state) { case AutomateState.ReadBranch: { t = reader.ReadMapToken(); msb.AppendRouteToken(positionWithOutMap2TypeHead(ref reader) - 1, t); stack.PushToken(t); if (t >= BssMapRouteToken.EqualNext1 && t <= BssMapRouteToken.EqualNext8 || t >= BssMapRouteToken.EqualLast1 && t <= BssMapRouteToken.EqualLast8) { if (t >= BssMapRouteToken.EqualNext1 && t <= BssMapRouteToken.EqualNext8) { long position = positionWithOutMap2TypeHead(ref reader); reader.EnsureType(BssomBinaryPrimitives.FixUInt16); msb.AppendNextOff(position, reader.ReadUInt16WithOutTypeHead()); } nextKeyByteCount = BssMapRouteTokenHelper.GetEqualNextOrLastByteCount(t); goto case AutomateState.ReadKey; } else if (t == BssMapRouteToken.EqualNextN || t == BssMapRouteToken.EqualLastN) { if (t == BssMapRouteToken.EqualNextN) { long position = positionWithOutMap2TypeHead(ref reader); reader.EnsureType(BssomBinaryPrimitives.FixUInt16); msb.AppendNextOff(position, reader.ReadUInt16WithOutTypeHead()); } ulong uint64Val = reader.ReadUInt64WithOutTypeHead(); msb.AppendUInt64Val(positionWithOutMap2TypeHead(ref reader) - 8, uint64Val); goto case AutomateState.ReadBranch; } else if (t >= BssMapRouteToken.LessThen1 && t <= BssMapRouteToken.LessThen8) { long position = positionWithOutMap2TypeHead(ref reader); reader.EnsureType(BssomBinaryPrimitives.FixUInt16); msb.AppendNextOff(position, reader.ReadUInt16WithOutTypeHead()); nextKeyByteCount = BssMapRouteTokenHelper.GetLessThenByteCount(t); position = positionWithOutMap2TypeHead(ref reader); if (nextKeyByteCount == 8) { msb.AppendUInt64Val(position, reader.ReadUInt64WithOutTypeHead()); } else { msb.AppendUInt64Val(position, ref reader.BssomBuffer.ReadRef(nextKeyByteCount), nextKeyByteCount); reader.BssomBuffer.SeekWithOutVerify(nextKeyByteCount, BssomSeekOrgin.Current); } goto case AutomateState.ReadBranch; } else if (t == BssMapRouteToken.LessElse) { goto case AutomateState.ReadBranch; } else { throw BssomSerializationOperationException.UnexpectedCodeRead((byte)t, reader.Position); } } case AutomateState.ReadKey: { if (nextKeyByteCount == 8) { ulong uint64Val = reader.ReadUInt64WithOutTypeHead(); msb.AppendUInt64Val(positionWithOutMap2TypeHead(ref reader) - 8, uint64Val); } else { //Read Raw(lessthan 8 byte) ref byte ref1 = ref reader.BssomBuffer.ReadRef(nextKeyByteCount); msb.AppendUInt64Val(positionWithOutMap2TypeHead(ref reader) - nextKeyByteCount, ref ref1, nextKeyByteCount); reader.BssomBuffer.SeekWithOutVerify(nextKeyByteCount, BssomSeekOrgin.Current); } long position = positionWithOutMap2TypeHead(ref reader); byte keyType = reader.ReadBssomType(); if (keyType == BssomType.NativeCode) { msb.AppendKeyType(position, true, reader.ReadBssomType()); } else { msb.AppendKeyType(position, false, keyType); } position = positionWithOutMap2TypeHead(ref reader); reader.EnsureType(BssomBinaryPrimitives.FixUInt32); msb.AppendValOffset(position, reader.ReadUInt32WithOutTypeHead()); count--; goto case AutomateState.ReadChildren; }
public Int64 Deserialize(ref BssomReader reader, ref BssomDeserializeContext context) { return(reader.ReadInt64()); }
public _Attribute_Class_3 Deserialize(ref BssomReader reader, ref BssomDeserializeContext context) { return(MapCodeGenResolver.Instance.GetFormatter <_Attribute_Class_3>().Deserialize(ref reader, ref context)); }
public static T ReadElement(ref BssomReader reader, BssomSerializerOptions option, BssomFieldOffsetInfo offsetInfo) { return(_controller.ReadElement(ref reader, option, offsetInfo)); }