public int Size(ref BssomSizeContext context, IDictionary value) { return(MapFormatterHelper.SizeIDictionary(ref context, value)); }
public IDictionary Deserialize(ref BssomReader reader, ref BssomDeserializeContext context) { return(MapFormatterHelper.GenericDictionaryDeserialize <object, object>(ref reader, ref context)); }
public void Serialize(ref BssomWriter writer, ref BssomSerializeContext context, IDictionary value) { MapFormatterHelper.SerializeIDictionary(ref writer, ref context, value); }
public static object DeserializeBssObject(ref BssomReader reader, ref BssomDeserializeContext context, bool isPriorityToDeserializeObjectAsBssomValue) { byte type = reader.SkipBlankCharacterAndPeekBssomType(); switch (type) { case BssomType.NullCode: reader.BssomBuffer.SeekWithOutVerify(1, BssomSeekOrgin.Current); if (isPriorityToDeserializeObjectAsBssomValue) { return(BssomNull.Value); } return(null); case BssomType.BooleanCode: reader.BssomBuffer.SeekWithOutVerify(1, BssomSeekOrgin.Current); if (isPriorityToDeserializeObjectAsBssomValue) { return(new BssomBoolean(reader.ReadBooleanWithOutTypeHead())); } return(reader.ReadBooleanWithOutTypeHead()); case BssomType.Int32Code: reader.BssomBuffer.SeekWithOutVerify(1, BssomSeekOrgin.Current); if (isPriorityToDeserializeObjectAsBssomValue) { return(new BssomNumber(reader.ReadInt32WithOutTypeHead())); } return(reader.ReadInt32WithOutTypeHead()); case BssomType.Int16Code: reader.BssomBuffer.SeekWithOutVerify(1, BssomSeekOrgin.Current); if (isPriorityToDeserializeObjectAsBssomValue) { return(new BssomNumber(reader.ReadInt16WithOutTypeHead())); } return(reader.ReadInt16WithOutTypeHead()); case BssomType.Int64Code: reader.BssomBuffer.SeekWithOutVerify(1, BssomSeekOrgin.Current); if (isPriorityToDeserializeObjectAsBssomValue) { return(new BssomNumber(reader.ReadInt64WithOutTypeHead())); } return(reader.ReadInt64WithOutTypeHead()); case BssomType.UInt64Code: reader.BssomBuffer.SeekWithOutVerify(1, BssomSeekOrgin.Current); if (isPriorityToDeserializeObjectAsBssomValue) { return(new BssomNumber(reader.ReadUInt64WithOutTypeHead())); } return(reader.ReadUInt64WithOutTypeHead()); case BssomType.UInt32Code: reader.BssomBuffer.SeekWithOutVerify(1, BssomSeekOrgin.Current); if (isPriorityToDeserializeObjectAsBssomValue) { return(new BssomNumber(reader.ReadUInt32WithOutTypeHead())); } return(reader.ReadUInt32WithOutTypeHead()); case BssomType.UInt16Code: reader.BssomBuffer.SeekWithOutVerify(1, BssomSeekOrgin.Current); if (isPriorityToDeserializeObjectAsBssomValue) { return(new BssomNumber(reader.ReadUInt16WithOutTypeHead())); } return(reader.ReadUInt16WithOutTypeHead()); case BssomType.UInt8Code: reader.BssomBuffer.SeekWithOutVerify(1, BssomSeekOrgin.Current); if (isPriorityToDeserializeObjectAsBssomValue) { return(new BssomNumber(reader.ReadUInt8WithOutTypeHead())); } return(reader.ReadUInt8WithOutTypeHead()); case BssomType.Int8Code: reader.BssomBuffer.SeekWithOutVerify(1, BssomSeekOrgin.Current); if (isPriorityToDeserializeObjectAsBssomValue) { return(new BssomNumber(reader.ReadInt8WithOutTypeHead())); } return(reader.ReadInt8WithOutTypeHead()); case BssomType.Float32Code: reader.BssomBuffer.SeekWithOutVerify(1, BssomSeekOrgin.Current); if (isPriorityToDeserializeObjectAsBssomValue) { return(new BssomFloat(reader.ReadFloat32WithOutTypeHead())); } return(reader.ReadFloat32WithOutTypeHead()); case BssomType.Float64Code: reader.BssomBuffer.SeekWithOutVerify(1, BssomSeekOrgin.Current); if (isPriorityToDeserializeObjectAsBssomValue) { return(new BssomFloat(reader.ReadFloat64WithOutTypeHead())); } return(reader.ReadFloat64WithOutTypeHead()); case BssomType.TimestampCode: reader.BssomBuffer.SeekWithOutVerify(1, BssomSeekOrgin.Current); if (isPriorityToDeserializeObjectAsBssomValue) { return(new BssomDateTime(reader.ReadStandDateTimeWithOutTypeHead())); } return(reader.ReadStandDateTimeWithOutTypeHead()); case BssomType.StringCode: reader.BssomBuffer.SeekWithOutVerify(1, BssomSeekOrgin.Current); if (isPriorityToDeserializeObjectAsBssomValue) { return(new BssomString(reader.ReadStringWithOutTypeHead())); } return(reader.ReadStringWithOutTypeHead()); case BssomType.NativeCode: { reader.BssomBuffer.SeekWithOutVerify(1, BssomSeekOrgin.Current); type = reader.ReadBssomType(); switch (type) { case NativeBssomType.CharCode: if (isPriorityToDeserializeObjectAsBssomValue) { return(new BssomChar(reader.ReadCharWithOutTypeHead())); } return(reader.ReadCharWithOutTypeHead()); case NativeBssomType.DecimalCode: if (isPriorityToDeserializeObjectAsBssomValue) { return(new BssomDecimal(reader.ReadDecimalWithOutTypeHead())); } return(reader.ReadDecimalWithOutTypeHead()); case NativeBssomType.DateTimeCode: if (isPriorityToDeserializeObjectAsBssomValue) { return(new BssomDateTime(reader.ReadNativeDateTimeWithOutTypeHead())); } return(reader.ReadNativeDateTimeWithOutTypeHead()); case NativeBssomType.GuidCode: if (isPriorityToDeserializeObjectAsBssomValue) { return(new BssomGuid(reader.ReadGuidWithOutTypeHead())); } return(reader.ReadGuidWithOutTypeHead()); } } break; case BssomType.Array1: { reader.BssomBuffer.SeekWithOutVerify(1, BssomSeekOrgin.Current); byte eleType = reader.ReadBssomType(); if (eleType != BssomType.NativeCode) { reader.BssomBuffer.Seek(-BssomBinaryPrimitives.Array1BuildInTypeCodeSize, BssomSeekOrgin.Current); } switch (eleType) { case BssomType.BooleanCode: return(new BssomArray(BooleanListFormatter.Instance.Deserialize(ref reader, ref context), false)); case BssomType.Int32Code: return(new BssomArray(Int32ListFormatter.Instance.Deserialize(ref reader, ref context), false)); case BssomType.Int16Code: return(new BssomArray(Int16ListFormatter.Instance.Deserialize(ref reader, ref context), false)); case BssomType.Int64Code: return(new BssomArray(Int64ListFormatter.Instance.Deserialize(ref reader, ref context), false)); case BssomType.UInt64Code: return(new BssomArray(UInt64ListFormatter.Instance.Deserialize(ref reader, ref context), false)); case BssomType.UInt32Code: return(new BssomArray(UInt32ListFormatter.Instance.Deserialize(ref reader, ref context), false)); case BssomType.UInt16Code: return(new BssomArray(UInt16ListFormatter.Instance.Deserialize(ref reader, ref context), false)); case BssomType.UInt8Code: return(new BssomArray(UInt8ListFormatter.Instance.Deserialize(ref reader, ref context), false)); case BssomType.Int8Code: return(new BssomArray(Int8ListFormatter.Instance.Deserialize(ref reader, ref context), false)); case BssomType.Float32Code: return(new BssomArray(Float32ListFormatter.Instance.Deserialize(ref reader, ref context), false)); case BssomType.Float64Code: return(new BssomArray(Float64ListFormatter.Instance.Deserialize(ref reader, ref context), false)); case BssomType.TimestampCode: return(new BssomArray(DateTimeListFormatter.Instance.Deserialize(ref reader, ref context), false)); case BssomType.NativeCode: { type = reader.ReadBssomType(); reader.BssomBuffer.Seek(-BssomBinaryPrimitives.Array1NativeTypeCodeSize, BssomSeekOrgin.Current); switch (type) { case NativeBssomType.CharCode: return(new BssomArray(CharListFormatter.Instance.Deserialize(ref reader, ref context), false)); case NativeBssomType.DecimalCode: return(new BssomArray(DecimalListFormatter.Instance.Deserialize(ref reader, ref context), false)); case NativeBssomType.DateTimeCode: return(new BssomArray(DateTimeListFormatter.Instance.Deserialize(ref reader, ref context), false)); case NativeBssomType.GuidCode: return(new BssomArray(GuidListFormatter.Instance.Deserialize(ref reader, ref context), false)); } break; } } break; } case BssomType.Array2: { reader.BssomBuffer.SeekWithOutVerify(1, BssomSeekOrgin.Current); reader.SkipVariableNumber(); int count = reader.ReadVariableNumber(); List <object> ary = new List <object>(count); for (int i = 0; i < count; i++) { ary.Add(DeserializeBssObject(ref reader, ref context, isPriorityToDeserializeObjectAsBssomValue)); } return(new BssomArray(ary, false)); } case BssomType.Map1: case BssomType.Map2: { return(new BssomMap(MapFormatterHelper.GenericDictionaryDeserialize <object, object>(ref reader, ref context))); } } throw BssomSerializationOperationException.UnexpectedCodeRead(type, reader.Position); }
public int Size(ref BssomSizeContext context, BssomMap value) { return(MapFormatterHelper.SizeGenericDictionary(ref context, value.GetMap())); }
public void Serialize(ref BssomWriter writer, ref BssomSerializeContext context, BssomMap value) { MapFormatterHelper.SerializeGenericDictionary(ref writer, ref context, value.GetMap()); }