Exemplo n.º 1
0
 /// <summary>
 /// Returns the offset (in <see cref="fullStream"/>) of a row
 /// </summary>
 /// <param name="table">Table</param>
 /// <param name="rid">A valid row ID (i.e., &gt;= <c>1</c> and &lt;= number of rows)</param>
 /// <param name="offset">Updated with the offset</param>
 /// <returns><c>true</c> if the row exists, <c>false</c> if the row doesn't exist</returns>
 protected abstract bool GetRowOffset(MDTable table, uint rid, out long offset);
Exemplo n.º 2
0
        /// <summary>
        /// Gets a rid list (eg. field list)
        /// </summary>
        /// <param name="tableSource">Source table, eg. <c>TypeDef</c></param>
        /// <param name="tableSourceRid">Row ID in <paramref name="tableSource"/></param>
        /// <param name="colIndex">Column index in <paramref name="tableSource"/>, eg. 4 for <c>TypeDef.FieldList</c></param>
        /// <param name="tableDest">Destination table, eg. <c>Field</c></param>
        /// <returns>A new <see cref="RidList"/> instance</returns>
        private RidList GetRidList(MDTable tableSource, uint tableSourceRid, int colIndex, MDTable tableDest)
        {
            var  column = tableSource.TableInfo.Columns[colIndex];
            uint startRid, nextListRid;
            bool hasNext;

#if THREAD_SAFE
            tablesStream.theLock.EnterWriteLock(); try {
#endif
            if (!tablesStream.ReadColumn_NoLock(tableSource, tableSourceRid, column, out startRid))
            {
                return(RidList.Empty);
            }
            hasNext = tablesStream.ReadColumn_NoLock(tableSource, tableSourceRid + 1, column, out nextListRid);
#if THREAD_SAFE
        }

        finally { tablesStream.theLock.ExitWriteLock(); }
#endif
            uint lastRid = tableDest.Rows + 1;
            if (startRid == 0 || startRid >= lastRid)
            {
                return(RidList.Empty);
            }
            uint endRid = hasNext ? nextListRid : lastRid;
            if (endRid < startRid)
            {
                endRid = startRid;
            }
            if (endRid > lastRid)
            {
                endRid = lastRid;
            }
            return(new ContiguousRidList(startRid, endRid - startRid));
        }