internal void EnsureNativeTypeWithSkipBlankCharacter(byte nativeType) { if (SkipBlankCharacterAndReadBssomType() != BssomType.NativeCode || ReadBssomType() != nativeType) { BssomSerializationOperationException.UnexpectedCodeRead(Position); } }
internal void EnsureNativeType(byte nativeType) { if (ReadBssomType() != BssomType.NativeCode || ReadBssomType() != nativeType) { BssomSerializationOperationException.UnexpectedCodeRead(Position); } }
public void EnsureType(byte buildInType) { byte t = ReadOne <byte>(); if (t != buildInType) { BssomSerializationOperationException.UnexpectedCodeRead(t, Position); } }
internal void EnsureMapToken(BssMapRouteToken token) { BssMapRouteToken t = ReadOne <BssMapRouteToken>(); if (t != token) { BssomSerializationOperationException.UnexpectedCodeRead((byte)t, Position); } }
internal void SkipBlankCharacterAndEnsureType(byte buildInType) { byte t = SkipBlankCharacterAndReadBssomType(); if (t != buildInType) { BssomSerializationOperationException.UnexpectedCodeRead(t, Position); } }
internal bool TryReadNullWithEnsureBuildInType(byte buildInType) { byte type = SkipBlankCharacterAndPeekBssomType(); if (type == BssomType.NullCode) { BssomBuffer.SeekWithOutVerify(BssomBinaryPrimitives.NullSize, BssomSeekOrgin.Current); return(true); } else if (type == buildInType) { BssomBuffer.SeekWithOutVerify(BssomBinaryPrimitives.BuildInTypeCodeSize, BssomSeekOrgin.Current); return(false); } return(BssomSerializationOperationException.UnexpectedCodeRead <bool>(type, Position)); }
internal DateTime ReadDateTime() { byte type = SkipBlankCharacterAndReadBssomType(); switch (type) { case BssomType.TimestampCode: return(ReadStandDateTimeWithOutTypeHead()); case BssomType.NativeCode: EnsureType(NativeBssomType.DateTimeCode); return(ReadNativeDateTimeWithOutTypeHead()); default: throw BssomSerializationOperationException.UnexpectedCodeRead(type, BssomBuffer.Position); } }
internal void SkipStandDateTimeWithOutTypeHead() { byte code = BssomBuffer.ReadRef(1); if (code == 4) { BssomBuffer.Seek(5, BssomSeekOrgin.Current); } else if (code == 8) { BssomBuffer.Seek(9, BssomSeekOrgin.Current); } else if (code == 12) { BssomBuffer.Seek(13, BssomSeekOrgin.Current); } else { throw BssomSerializationOperationException.UnexpectedCodeRead(code, BssomBuffer.Position); } }
private int GetSizeOfOneObjectToBuffer() { int size; byte objType = GetBssomTypeFromStreamPack.Get(stream, buffer); buffer[0] = objType; position++; if (!BssomBinaryPrimitives.TryGetPrimitiveTypeSizeFromStaticTypeSizes(objType, out size)) { switch (objType) { case BssomType.StringCode: size = (int)ReadVariableNumberCore(); break; case BssomType.NativeCode: { ReadStreamToBuffer(1); objType = buffer[position - 1]; if (objType == NativeBssomType.CharCode) { size = BssomBinaryPrimitives.CharSize; } else if (objType == NativeBssomType.DateTimeCode) { size = BssomBinaryPrimitives.NativeDateTimeSize; } else if (objType == NativeBssomType.DecimalCode) { size = BssomBinaryPrimitives.DecimalSize; } else if (objType == NativeBssomType.GuidCode) { size = BssomBinaryPrimitives.GuidSize; } else { throw BssomSerializationOperationException.UnexpectedCodeRead(objType); } break; } case BssomType.Map1: case BssomType.Map2: case BssomType.Array2: size = (int)ReadVariableNumberCore(); break; case BssomType.Array1: { ReadStreamToBuffer(1); if (buffer[position - 1] /*elementType*/ == BssomType.NativeCode) { ReadStreamToBuffer(1); } size = (int)ReadVariableNumberCore(); break; } default: throw BssomSerializationOperationException.UnexpectedCodeRead(objType); } } return(size); }