static int GetItemIndex(IList <Tuple <Record, TES3GameItem> > registry, TES3GameItem item) { var index = -1; foreach (var current in registry) { ++index; if (current.Item2 == item) { return(index); } } return(-1); }
void HandleCommonCache(string modFileName, TES3GameItem item) { var key = new GameItemKey(modFileName, item.Id); if (gameItemsByIdAndFile.ContainsKey(key)) { throw new InvalidOperationException($"Key already present for ModFile {modFileName}: {item.Id}({item.GetType()}); Current is {gameItemsByIdAndFile[key]}"); } gameItemsByIdAndFile.Add(key, item); var version = new GameItemVersion <TES3GameItem>(modFileName, item); gameItemVersionsById[item.Id].Add(version); gameItemVersionsByType[item.GetType()].Add(version); gameItemsByTypeAndFile[new TypeKey(modFileName, item.GetType())].Add(item); gameItemOwnership.Add(item, modFileName); item.IdChanged += OnIdChange; }