public BlobCell(StructField def, Stream baseStream, int offset, int baseSize, BlobDecoder decoder, int decodedSize) : base(def, null, offset) { _baseStream = baseStream; _baseSize = baseSize; _decoder = decoder; _decodedSize = decodedSize; }
public BlobCell(StructField def, Stream baseStream, int offset, int baseSize, BlobDecoder decoder, int decodedSize) : base(def, null, offset) { _baseStream = baseStream; _baseSize = baseSize; _decoder = decoder; _decodedSize = decodedSize; }
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)); } }