public LiftedList <T> LoadDirectChildren <T>( MetadataTable childTable, GetTokenDelegate tokenSelector, CreateObjectDelegateEX <T> factory, MetadataTable parentTable, void *parentRow ) where T : class { var firstMemberIndex = (ZeroBasedIndex)tokenSelector(parentRow); ZeroBasedIndex lastMemberIndex; var tableIndex = GetRowIndex(parentTable, parentRow); if (tableIndex == GetRowCount(parentTable) - 1) { lastMemberIndex = new ZeroBasedIndex(GetRowCount(childTable)); } else { lastMemberIndex = (ZeroBasedIndex)tokenSelector(GetRow(tableIndex + 1, parentTable)); } var ret = new LiftedList <T>( (lastMemberIndex - firstMemberIndex).Value, index => GetRow(firstMemberIndex + index, childTable), factory, () => IsDisposed ); return(ret); }
public LiftedList <T> LoadDirectChildren <T>( MetadataTable childTable, GetTokenDelegate tokenSelector, CreateObjectDelegate <T> factory, MetadataTable parentTable, void *parentRow ) where T : class { factory.CheckNotNull("factory"); return(LoadDirectChildren(childTable, tokenSelector, (pRow, index) => factory(pRow), parentTable, parentRow)); }
//TODO: Factor GetMembers into a general helper in PEFile, so that it can also be used by //MethodDefinition. LiftedList <T> LoadDirectChildren <T>( MetadataTable childTable, GetTokenDelegate tokenSelector, CreateObjectDelegate <T> createObject ) where T : class { return(Module.PEFile.LoadDirectChildren( childTable, tokenSelector, createObject, MetadataTable.TypeDef, m_pRow )); }
public ISubList <T> LoadDirectChildren <T>( MetadataTable childTable, GetTokenDelegate tokenSelector, MetadataTable parentTable, void *parentRow, IReadOnlyList <T> sourceList ) where T : class { var firstMemberIndex = (ZeroBasedIndex)tokenSelector(parentRow); ZeroBasedIndex lastMemberIndex; var tableIndex = GetRowIndex(parentTable, parentRow); if (tableIndex == GetRowCount(parentTable) - 1) { lastMemberIndex = new ZeroBasedIndex(GetRowCount(childTable)); } else { lastMemberIndex = (ZeroBasedIndex)tokenSelector(GetRow(tableIndex + 1, parentTable)); } return(sourceList.SubList(firstMemberIndex.Value, (lastMemberIndex - firstMemberIndex).Value)); }
IReadOnlyList <T> LoadDirectChildrenFromMap <T>( MetadataTable mapTable, MetadataTable childTable, UnsafeSelector <OneBasedIndex> parentSelector, GetTokenDelegate tokenSelector, CreateObjectDelegate <T> factory ) where T : class { //It is valid for the map table to not be sorted. However, I don't expect this to happen in //practice, so for now we throw an exception in that case. If we do end up needing to support //assemblies with unsorted meta-data tables then we will need to add some sort of fallback //here. mapTable.IsSorted(Module.PEFile).Assume("The table is not sorted"); var mapIndex = mapTable.Find( (OneBasedIndex)MetadataTable.TypeDef.RowIndex(m_pRow, Module.PEFile), parentSelector, Module.PEFile ); IReadOnlyList <T> ret; if (mapIndex < 0) { ret = new List <T>(0).AsReadOnly(); } else { ret = Module.PEFile.LoadDirectChildren( childTable, tokenSelector, factory, mapTable, mapTable.GetRow(mapIndex, Module.PEFile) ); } return(ret); }