protected bool CheckToWeakRegisterExistingExtensions(ConversionKey conversionKey, ClassTupleEntry <V> classEntry)
        {
            bool changesHappened = false;

            foreach (Entry <Strong2Key <V>, List <Def2Entry <V> > > entry in classEntry.definitionReverseMap)
            {
                Strong2Key <V> strongKey           = entry.Key;
                ConversionKey  registeredStrongKey = strongKey.key;
                int            sourceDistance      = ClassExtendableContainer <V> .GetDistanceForType(conversionKey.SourceType, registeredStrongKey.SourceType);

                if (sourceDistance == ClassExtendableContainer <V> .NO_VALID_DISTANCE)
                {
                    continue;
                }
                int targetDistance = ClassExtendableContainer <V> .GetDistanceForType(registeredStrongKey.TargetType, conversionKey.TargetType);

                if (targetDistance == ClassExtendableContainer <V> .NO_VALID_DISTANCE)
                {
                    continue;
                }
                List <Def2Entry <V> > defEntries = entry.Value;
                for (int a = defEntries.Count; a-- > 0;)
                {
                    Def2Entry <V> defEntry = defEntries[a];
                    changesHappened |= AppendRegistration(registeredStrongKey, conversionKey, defEntry.extension, sourceDistance, targetDistance, classEntry);
                }
            }
            return(changesHappened);
        }
Exemple #2
0
        public override bool Equals(Object obj)
        {
            if (obj == this)
            {
                return(true);
            }
            if (!(obj is Strong2Key <V>))
            {
                return(false);
            }
            Strong2Key <V> other = (Strong2Key <V>)obj;

            return(Object.ReferenceEquals(extension, other.extension) && key.Equals(other.key));
        }
        protected bool AppendRegistration(ConversionKey strongTypeKey, ConversionKey key, V extension, int sourceDistance, int targetDistance,
                                          ClassTupleEntry <V> classEntry)
        {
            HashMap <ConversionKey, Object> typeToDefEntryMap = classEntry.typeToDefEntryMap;
            Object fastList = typeToDefEntryMap.Get(key);

            if (fastList != null && fastList != alreadyHandled)
            {
                IListElem <Def2Entry <V> > pointer = ((InterfaceFastList <Def2Entry <V> >)fastList).First;
                while (pointer != null)
                {
                    Def2Entry <V> existingDefEntry = pointer.ElemValue;
                    if (Object.ReferenceEquals(existingDefEntry.extension, extension) && existingDefEntry.sourceDistance == sourceDistance &&
                        existingDefEntry.targetDistance == targetDistance)
                    {
                        // DefEntry already exists with same distance
                        return(false);
                    }
                    pointer = pointer.Next;
                }
            }
            if (fastList == null || Object.ReferenceEquals(fastList, alreadyHandled))
            {
                fastList = new InterfaceFastList <Def2Entry <V> >();
                typeToDefEntryMap.Put(key, fastList);
            }
            Def2Entry <V> defEntry = new Def2Entry <V>(extension, key.SourceType, key.TargetType, sourceDistance, targetDistance);

            HashMap <Strong2Key <V>, List <Def2Entry <V> > > definitionReverseMap = classEntry.definitionReverseMap;
            Strong2Key <V>        strongKey   = new Strong2Key <V>(extension, strongTypeKey);
            List <Def2Entry <V> > typeEntries = definitionReverseMap.Get(strongKey);

            if (typeEntries == null)
            {
                typeEntries = new List <Def2Entry <V> >();
                definitionReverseMap.Put(strongKey, typeEntries);
            }
            typeEntries.Add(defEntry);

            InterfaceFastList <Def2Entry <V> > .InsertOrdered((InterfaceFastList <Def2Entry <V> >) fastList, defEntry);

            TypeToDefEntryMapChanged(classEntry, key);
            return(true);
        }