protected override void TypeToDefEntryMapChanged(ClassEntry <V> classEntry, Type key) { Object obj = classEntry.typeToDefEntryMap.Get(key); if (obj == null) { classEntry.Remove(key); return; } if (obj == alreadyHandled) { classEntry.Put(key, alreadyHandled); return; } Object existingItem = classEntry.Get(key); List <V> list = (List <V>)(existingItem == alreadyHandled ? null : existingItem); if (list == null) { list = new List <V>(); classEntry.Put(key, list); } if (obj is DefEntry <V> ) { V extension = ((DefEntry <V>)obj).extension; if (!list.Contains(extension)) { list.Add(extension); } return; } IListElem <DefEntry <V> > pointer = ((InterfaceFastList <DefEntry <V> >)obj).First; while (pointer != null) { V extension = pointer.ElemValue.extension; if (!list.Contains(extension)) { list.Add(extension); } pointer = pointer.Next; } }
public override V GetExtension(Type key) { if (key == null) { return(default(V)); } Object extension = this.classEntry.Get(key); if (extension == null) { Object writeLock = GetWriteLock(); lock (writeLock) { extension = this.classEntry.Get(key); if (extension == null) { ClassEntry <V> classEntry = CopyStructure(); classEntry.Put(key, alreadyHandled); classEntry.typeToDefEntryMap.Put(key, alreadyHandled); CheckToWeakRegisterExistingExtensions(key, classEntry); this.classEntry = classEntry; extension = classEntry.Get(key); if (extension == null) { return(default(V)); } } } } if (Object.ReferenceEquals(extension, alreadyHandled)) { // Already tried return(default(V)); } return((V)extension); }