コード例 #1
0
ファイル: BlobField.cs プロジェクト: thawk/structorian
        public override void LoadData(BinaryReader reader, StructInstance instance)
        {
            int offset = (int)reader.BaseStream.Position;
            int len;
            try
            {
                len = GetExpressionAttribute("len").EvaluateInt(instance);
            }
            catch (OverflowException)
            {
                throw new LoadDataException("Blob size is larger than Int32");
            }
            if (offset + len > reader.BaseStream.Length)
                throw new LoadDataException("Blob size " + len + " exceeds stream length");
            if (len < 0)
                throw new LoadDataException("Blob size " + len + " is negative");
            var decodedSizeExpr = GetExpressionAttribute("decodedsize");
            int decodedSize = decodedSizeExpr != null ? decodedSizeExpr.EvaluateInt(instance) : -1;
            string encoding = GetStringAttribute("encoding");
            BlobDecoder blobDecoder = FindBlobEncoding(instance, encoding);
            BlobCell cell = new BlobCell(this, reader.BaseStream, offset, len, blobDecoder, decodedSize);
            instance.AddCell(cell, _hidden);
            instance.RegisterCellSize(cell, len);
            reader.BaseStream.Position += len;

            StructDef structDef = GetStructAttribute("struct");
            if (structDef != null)
                instance.AddChildSeed(new BlobChildSeed(structDef, cell));
        }
コード例 #2
0
ファイル: ChildField.cs プロジェクト: thawk/structorian
 public override void LoadData(BinaryReader reader, StructInstance instance)
 {
     long? offset = EvaluateOffset(instance);
     int count = EvaluateCount(instance);
     if (_isSibling)
         DoLoadChildren(instance, instance.Parent, reader.BaseStream, offset, count);
     else
     {
         instance.AddChildSeed(new ChildSeed(this, offset, count, _isSibling));
     }
 }
コード例 #3
0
ファイル: ChildField.cs プロジェクト: yole/structorian
        public override void LoadData(BinaryReader reader, StructInstance instance)
        {
            long?offset = EvaluateOffset(instance);
            int  count  = EvaluateCount(instance);

            if (_isSibling)
            {
                DoLoadChildren(instance, instance.Parent, reader.BaseStream, offset, count);
            }
            else
            {
                instance.AddChildSeed(new ChildSeed(this, offset, count, _isSibling));
            }
        }
コード例 #4
0
        public override void LoadData(BinaryReader reader, StructInstance instance)
        {
            int offset = (int)reader.BaseStream.Position;
            int len;

            try
            {
                len = GetExpressionAttribute("len").EvaluateInt(instance);
            }
            catch (OverflowException)
            {
                throw new LoadDataException("Blob size is larger than Int32");
            }
            if (offset + len > reader.BaseStream.Length)
            {
                throw new LoadDataException("Blob size " + len + " exceeds stream length");
            }
            if (len < 0)
            {
                throw new LoadDataException("Blob size " + len + " is negative");
            }
            var decodedSizeExpr = GetExpressionAttribute("decodedsize");
            int decodedSize     = decodedSizeExpr != null?decodedSizeExpr.EvaluateInt(instance) : -1;

            string      encoding    = GetStringAttribute("encoding");
            BlobDecoder blobDecoder = FindBlobEncoding(instance, encoding);
            BlobCell    cell        = new BlobCell(this, reader.BaseStream, offset, len, blobDecoder, decodedSize);

            instance.AddCell(cell, _hidden);
            instance.RegisterCellSize(cell, len);
            reader.BaseStream.Position += len;

            StructDef structDef = GetStructAttribute("struct");

            if (structDef != null)
            {
                instance.AddChildSeed(new BlobChildSeed(structDef, cell));
            }
        }