public override bool Equals(Object obj) { if (obj == this) { return(true); } if (!(obj is StrongKey <V>)) { return(false); } StrongKey <V> other = (StrongKey <V>)obj; return(Object.ReferenceEquals(extension, other.extension) && strongType.Equals(other.strongType)); }
protected bool AppendRegistration(Type strongType, Type type, V extension, int distance, ClassEntry <V> classEntry) { LinkedHashMap <Type, Object> typeToDefEntryMap = classEntry.typeToDefEntryMap; Object fastList = typeToDefEntryMap.Get(type); if (fastList != null && !Object.ReferenceEquals(fastList, alreadyHandled)) { IListElem <DefEntry <V> > pointer = ((InterfaceFastList <DefEntry <V> >)fastList).First; while (pointer != null) { DefEntry <V> existingDefEntry = pointer.ElemValue; if (Object.ReferenceEquals(existingDefEntry.extension, extension) && existingDefEntry.distance == distance) { // DefEntry already exists with same distance return(false); } pointer = pointer.Next; } } if (fastList == null || Object.ReferenceEquals(fastList, alreadyHandled)) { fastList = new InterfaceFastList <DefEntry <V> >(); typeToDefEntryMap.Put(type, fastList); } DefEntry <V> defEntry = new DefEntry <V>(extension, type, distance); LinkedHashMap <StrongKey <V>, List <DefEntry <V> > > definitionReverseMap = classEntry.definitionReverseMap; StrongKey <V> strongKey = new StrongKey <V>(extension, strongType); List <DefEntry <V> > typeEntries = definitionReverseMap.Get(strongKey); if (typeEntries == null) { typeEntries = new List <DefEntry <V> >(); definitionReverseMap.Put(strongKey, typeEntries); } typeEntries.Add(defEntry); InterfaceFastList <DefEntry <V> > .InsertOrdered((InterfaceFastList <DefEntry <V> >) fastList, defEntry); TypeToDefEntryMapChanged(classEntry, type); return(true); }
protected bool CheckToWeakRegisterExistingExtensions(Type type, ClassEntry <V> classEntry) { bool changesHappened = false; foreach (Entry <StrongKey <V>, List <DefEntry <V> > > entry in classEntry.definitionReverseMap) { StrongKey <V> strongKey = entry.Key; Type registeredStrongType = strongKey.strongType; int distance = GetDistanceForType(type, registeredStrongType); if (distance == NO_VALID_DISTANCE) { continue; } List <DefEntry <V> > defEntries = entry.Value; for (int a = defEntries.Count; a-- > 0;) { DefEntry <V> defEntry = defEntries[a]; changesHappened |= AppendRegistration(registeredStrongType, type, defEntry.extension, distance, classEntry); } } return(changesHappened); }