public Lookup GetLookup(MetadataColumn column) { Lookup lookup; if (!_lookups.TryGetValue(column.Index, out lookup)) { lookup = new Lookup(); _lookups.Add(column.Index, lookup); } return(lookup); }
public MetadataCell this[MetadataColumn column] { get { if (column == null) { throw new ArgumentNullException("column"); } return(this[column.Index]); } }
public IEnumerable <MetadataRow> LookupRows(TableId tableId, MetadataColumn column, int target, bool simple) { var table = GetTable(tableId); if (table == null) { return(Enumerable.Empty <MetadataRow>()); } var lookup = table.GetLookup(column); IList <int> list; var rowCount = GetRowCount(tableId); while (lookup.LastIndex < rowCount) { var row = GetRow(tableId, lookup.LastIndex); int key = simple ? row[column].Index - 1 : (int)((SimpleIndex)row[column].Value); if (!lookup.TryGetValue(key, out list)) { list = new List <int>(); lookup.Add(key, list); } list.Add(lookup.LastIndex); for (lookup.LastIndex++; lookup.LastIndex < rowCount; lookup.LastIndex++) { row = GetRow(tableId, lookup.LastIndex); int key2 = simple ? row[column].Index - 1 : (int)((SimpleIndex)row[column].Value); if (key != key2) { break; } list.Add(lookup.LastIndex); } } if (lookup.TryGetValue(target, out list)) { return(GetRows(tableId, list)); } return(Enumerable.Empty <MetadataRow>()); }
public MetadataRow LookupRow(TableId tableId, MetadataColumn column, int target, bool simple) { var table = GetTable(tableId); if (table == null) { return(null); } var lookup = table.GetLookup(column); IList <int> list; if (lookup.TryGetValue(target, out list)) { return(GetRow(tableId, list[0])); } var rowCount = GetRowCount(tableId); for (; lookup.LastIndex < rowCount; lookup.LastIndex++) { var row = GetRow(tableId, lookup.LastIndex); int index = simple ? row[column].Index - 1 : (int)((SimpleIndex)row[column].Value); if (index == target) { lookup.Add(target, new List <int> { lookup.LastIndex }); lookup.LastIndex++; return(row); } if (!lookup.TryGetValue(index, out list)) { list = new List <int>(); lookup.Add(index, list); } list.Add(lookup.LastIndex); } return(null); }
private int GetColumnSize(MetadataColumn c) { switch (c.Type) { case ColumnType.Int16: return(2); case ColumnType.Int32: return(4); case ColumnType.StringIndex: return(StringIndexSize); case ColumnType.BlobIndex: return(BlobIndexSize); case ColumnType.GuidIndex: return(GuidIndexSize); case ColumnType.SimpleIndex: return(GetSimpleIndexSize(c.SimpleIndex)); case ColumnType.CodedIndex: return(GetCodedIndexSize(c.CodedIndex)); default: throw new ArgumentOutOfRangeException(); } }
internal MetadataCell(MetadataReader metadata, MetadataColumn column, uint value) : this() { _metadata = metadata; Column = column; Value = value; }