コード例 #1
0
ファイル: BssomReader.cs プロジェクト: zqh2945/Bssom.Net
 internal void EnsureNativeTypeWithSkipBlankCharacter(byte nativeType)
 {
     if (SkipBlankCharacterAndReadBssomType() != BssomType.NativeCode || ReadBssomType() != nativeType)
     {
         BssomSerializationOperationException.UnexpectedCodeRead(Position);
     }
 }
コード例 #2
0
ファイル: BssomReader.cs プロジェクト: zqh2945/Bssom.Net
 internal void EnsureNativeType(byte nativeType)
 {
     if (ReadBssomType() != BssomType.NativeCode || ReadBssomType() != nativeType)
     {
         BssomSerializationOperationException.UnexpectedCodeRead(Position);
     }
 }
コード例 #3
0
ファイル: BssomReader.cs プロジェクト: zqh2945/Bssom.Net
        public void EnsureType(byte buildInType)
        {
            byte t = ReadOne <byte>();

            if (t != buildInType)
            {
                BssomSerializationOperationException.UnexpectedCodeRead(t, Position);
            }
        }
コード例 #4
0
ファイル: BssomReader.cs プロジェクト: zqh2945/Bssom.Net
        internal void EnsureMapToken(BssMapRouteToken token)
        {
            BssMapRouteToken t = ReadOne <BssMapRouteToken>();

            if (t != token)
            {
                BssomSerializationOperationException.UnexpectedCodeRead((byte)t, Position);
            }
        }
コード例 #5
0
ファイル: BssomReader.cs プロジェクト: zqh2945/Bssom.Net
        internal void SkipBlankCharacterAndEnsureType(byte buildInType)
        {
            byte t = SkipBlankCharacterAndReadBssomType();

            if (t != buildInType)
            {
                BssomSerializationOperationException.UnexpectedCodeRead(t, Position);
            }
        }
コード例 #6
0
ファイル: BssomReader.cs プロジェクト: zqh2945/Bssom.Net
        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));
        }
コード例 #7
0
ファイル: BssomReader.cs プロジェクト: zqh2945/Bssom.Net
        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);
            }
        }
コード例 #8
0
ファイル: BssomReader.cs プロジェクト: zqh2945/Bssom.Net
        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);
            }
        }
コード例 #9
0
        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);
        }