Exemplo n.º 1
0
        public override EsfNode Decode(BinaryReader reader, byte typeCode)
        {
            EsfNode result;
            byte    recordBit = (byte)(typeCode & RECORD_BIT);

            if (recordBit == 0 || reader.BaseStream.Position == headerLength + 1)
            {
                switch ((EsfType)typeCode)
                {
                case EsfType.INT32_ZERO:
                case EsfType.INT32_BYTE:
                case EsfType.INT32_SHORT:
                case EsfType.INT32_24BIT:
                case EsfType.INT32:
                    result = new OptimizedIntNode();
                    (result as OptimizedIntNode).Decode(reader, (EsfType)typeCode);
                    break;

                default:
                    // for non-blocks and root node, previous decoding is used
                    result = base.Decode(reader, typeCode);
                    break;
                }
            }
            else
            {
                bool blockBit = ((typeCode & BLOCK_BIT) != 0);
                // use new block decoding
                result = blockBit
                    ? ReadRecordArrayNode(reader, typeCode)
                    : ReadRecordNode(reader, typeCode);
            }
            return(result);
        }
Exemplo n.º 2
0
        public override EsfNode Decode(BinaryReader reader, byte typeCode)
        {
            EsfNode esfNode;

            if ((byte)(typeCode & RECORD_BIT) == 0 || reader.BaseStream.Position == headerLength + 1)
            {
                if (typeCode == 4 || (uint)(typeCode - 25) <= 3u)
                {
                    esfNode = new OptimizedIntNode();
                    (esfNode as OptimizedIntNode).Decode(reader, (EsfType)typeCode);
                }
                else
                {
                    esfNode = base.Decode(reader, typeCode);
                }
            }
            else
            {
                esfNode = (((typeCode & BLOCK_BIT) != 0)
                    ? ReadRecordArrayNode(reader, typeCode)
                    : ReadRecordNode(reader, typeCode));
            }

            return(esfNode);
        }