Ejemplo n.º 1
0
        public override void FromJson(JsonTextReader reader)
        {
            switch (reader.TokenType)
            {
            case JsonToken.String:
                string val = (string)reader.Value;
                if (val.StartsWith("!iar "))
                {
                    valueOffsetType.Type = 128;
                    complexValueData     = new PkgDataArrayReference(ParentFile);
                    complexValueData.FromJson(reader);
                }
                else
                {
                    ValueData = val;
                }
                break;

            case JsonToken.StartObject:
                valueOffsetType.Type = 128;
                complexValueData     = new PkgObject(ParentFile);
                complexValueData.FromJson(reader);
                break;

            case JsonToken.StartArray:
                valueOffsetType.Type = 128;
                complexValueData     = new PkgArray(ParentFile);
                complexValueData.FromJson(reader);
                break;

            default:
                new Exception("Unexpected token type! " + reader.TokenType);
                break;
            }
        }
Ejemplo n.º 2
0
        public override void Read(PkgBinaryReader reader)
        {
            valueOffsetType = reader.ReadOffsetType();


            if (valueOffsetType.Type == 128)
            {
                long pos = reader.BaseStream.Position;
                reader.Seek(valueOffsetType.Offset, SeekOrigin.Begin);

                string chunkType = reader.ReadString(4);
                switch (chunkType)
                {
                case "!idi":
                    complexValueData = new PkgObject(ParentFile);
                    complexValueData.Read(reader);
                    break;

                case "!ili":
                    complexValueData = new PkgArray(ParentFile);
                    complexValueData.Read(reader);
                    break;

                case "!iar":
                    complexValueData = new PkgDataArrayReference(ParentFile);
                    complexValueData.Read(reader);
                    break;

                case "!vca":
                    complexValueData = new PkgDataArray(ParentFile);
                    complexValueData.Read(reader);
                    break;

                case "!sbi":
                    complexValueData = PkgData.Create(ParentFile, "stri");
                    complexValueData.Read(reader);
                    break;

                case "!vbi":
                    complexValueData = PkgData.Create(reader, ParentFile);
                    complexValueData.Read(reader);
                    break;

                default:
                    throw new Exception("Chunk type not supported! " + chunkType);
                }

                reader.Seek((int)pos, SeekOrigin.Begin);
            }
        }