コード例 #1
0
ファイル: XstFile.cs プロジェクト: tenwx/XstReader
        public void SaveAttachment(Stream s, Attachment a)
        {
            using (FileStream fs = ndb.GetReadStream())
            {
                BTree <Node> subNodeTreeMessage = a.subNodeTreeProperties;

                if (subNodeTreeMessage == null)
                {
                    // No subNodeTree given: assume we can look it up in the main tree
                    ndb.LookupNodeAndReadItsSubNodeBtree(fs, a.Parent.Nid, out subNodeTreeMessage);
                }

                var subNodeTreeAttachment = ltp.ReadProperties <Attachment>(fs, subNodeTreeMessage, a.Nid, pgAttachmentContent, a);

                // If the value is inline, we just write it out
                if (a.Content.GetType() == typeof(byte[]))
                {
                    s.Write(a.Content, 0, a.Content.Length);
                }
                // Otherwise we need to dereference the node pointing to the data,
                // using the subnode tree belonging to the attachment
                else if (a.Content.GetType() == typeof(NID))
                {
                    var nb = NDB.LookupSubNode(subNodeTreeAttachment, (NID)a.Content);

                    // Copy the data to the output file stream without getting it all into memory at once,
                    // as there can be a lot of data
                    ndb.CopyDataBlocks(fs, s, nb.DataBid);
                }
            }
        }
コード例 #2
0
        // Read all of the data blocks for a table, in the case where the rows are to be accessed via a sub node
        // The variation here is that for reading rows, we need to retain the block structure, so we return a set of blocks
        private List <RowDataBlock> ReadSubNodeRowDataBlocks(FileStream fs, BTree <Node> subNodeTree, NID nid)
        {
            var blocks = new List <RowDataBlock>();
            var n      = NDB.LookupSubNode(subNodeTree, nid);

            if (n == null)
            {
                throw new XstException("Sub node NID not found");
            }
            if (n.SubDataBid != 0)
            {
                throw new XstException("Sub-nodes of sub-nodes not yet implemented");
            }

            foreach (var buf in ndb.ReadDataBlocks(fs, n.DataBid))
            {
                blocks.Add(new RowDataBlock
                {
                    Buffer = buf,
                    Offset = 0,
                    Length = buf.Length,
                });
            }

            return(blocks);
        }
コード例 #3
0
ファイル: XstFile.cs プロジェクト: nelsont/XstReader
 public XstFile(View view, string fullName)
 {
     this.ndb  = new NDB(fullName);
     this.ltp  = new LTP(ndb);
     this.view = view;
 }
コード例 #4
0
 public LTP(NDB ndb)
 {
     this.ndb = ndb;
 }
コード例 #5
0
 // Test for the  presence of an optional table in the supplied sub node tree
 public bool IsTablePresent(BTree <Node> subNodeTree, NID nid)
 {
     return(subNodeTree != null && NDB.LookupSubNode(subNodeTree, nid) != null);
 }
コード例 #6
0
ファイル: XstFile.cs プロジェクト: stephenjannin/XstReader
 public XstFile(string fullName)
 {
     this.ndb = new NDB(fullName);
     this.ltp = new LTP(ndb);
 }