public InstanceNameInfo(AncestorFeatureInfo item, IFeatureInstance instance, IFeatureName name)
 {
     Instance = instance;
     Name     = name;
     Ancestor = item.Ancestor;
     if (item.Location.IsAssigned)
     {
         Location = item.Location.Item;
     }
     else
     {
         Location = new Inheritance();
     }
     SameIsKept         = true;
     SameIsDiscontinued = true;
 }
        private void ListLocalAndInheritedFeatures(IClass item, IList <AncestorFeatureInfo> featureTableList)
        {
            AncestorFeatureInfo LocalFeatures = new AncestorFeatureInfo();

            LocalFeatures.Ancestor     = item.ResolvedClassType.Item;
            LocalFeatures.FeatureTable = item.LocalFeatureTable;
            LocalFeatures.Location     = new OnceReference <IInheritance>();
            featureTableList.Add(LocalFeatures);

            foreach (IInheritance InheritanceItem in item.InheritanceList)
            {
                AncestorFeatureInfo InheritedFeatures = new AncestorFeatureInfo();
                IClassType          InheritanceParent = InheritanceItem.ResolvedType.Item;
                InheritedFeatures.Ancestor      = InheritanceParent;
                InheritedFeatures.FeatureTable  = InheritanceParent.FeatureTable;
                InheritedFeatures.Location      = new OnceReference <IInheritance>();
                InheritedFeatures.Location.Item = InheritanceItem;
                featureTableList.Add(InheritedFeatures);
            }
        }
        private void UpdateNameList(AncestorFeatureInfo featureInfo, IFeatureName featureName, IFeatureInstance featureInstance, IList <InstanceNameInfo> nameList)
        {
            OnceReference <InstanceNameInfo> PreviousInstance = new OnceReference <InstanceNameInfo>();

            int i;

            for (i = 0; i < nameList.Count; i++)
            {
                InstanceNameInfo Item = nameList[i];
                if (featureName.Name == Item.Name.Name)
                {
                    PreviousInstance.Item = Item;
                    break;
                }
            }

            // C inherit f from A and B, effectively or not, but keep or discontinue flags don't match.
            if (PreviousInstance.IsAssigned && (PreviousInstance.Item.Instance.IsForgotten == featureInstance.IsForgotten))
            {
                PreviousInstance.Item.SameIsKept         = PreviousInstance.Item.Instance.IsKept == featureInstance.IsKept;
                PreviousInstance.Item.SameIsDiscontinued = PreviousInstance.Item.Instance.IsDiscontinued == featureInstance.IsDiscontinued;
            }

            if (!PreviousInstance.IsAssigned || (PreviousInstance.Item.Instance.IsForgotten && !featureInstance.IsForgotten))
            {
                InstanceNameInfo NewInfo = new InstanceNameInfo(featureInfo, featureInstance, featureName);
                if (i < nameList.Count)
                {
                    nameList[i] = NewInfo;
                }
                else
                {
                    nameList.Add(NewInfo);
                }
            }
        }
        private void CheckIfFeatureNameListed(ISealableDictionary <IFeatureName, InheritedInstanceInfo> byNameTable, AncestorFeatureInfo featureInfo, IFeatureName featureName, IFeatureInstance featureInstance)
        {
            bool FeatureAlreadyListed = false;
            bool NameAlreadyListed    = false;

            foreach (KeyValuePair <IFeatureName, InheritedInstanceInfo> ImportedEntry in byNameTable)
            {
                IFeatureName             ImportedKey      = ImportedEntry.Key;
                InheritedInstanceInfo    ImportedInstance = ImportedEntry.Value;
                IList <InstanceNameInfo> InstanceList     = ImportedInstance.PrecursorInstanceList;

                if (featureName.Name == ImportedKey.Name)
                {
                    FeatureAlreadyListed = false;

                    Debug.Assert(featureInstance.Feature != null);

                    foreach (InstanceNameInfo Item in InstanceList)
                    {
                        Debug.Assert(Item.Instance.Feature != null);

                        if (featureInstance.Feature == Item.Instance.Feature)
                        {
                            FeatureAlreadyListed = true;
                            break;
                        }
                    }

                    if (!FeatureAlreadyListed)
                    {
                        InstanceNameInfo NewInfo = new InstanceNameInfo(featureInfo, featureInstance, featureName);
                        InstanceList.Add(NewInfo);
                    }

                    NameAlreadyListed = true;
                    break;
                }
            }
            if (!NameAlreadyListed)
            {
                IList <InstanceNameInfo> InitList = new List <InstanceNameInfo>();
                InstanceNameInfo         NewInfo  = new InstanceNameInfo(featureInfo, featureInstance, featureName);
                InitList.Add(NewInfo);

                InheritedInstanceInfo NewName = new InheritedInstanceInfo();
                NewName.PrecursorInstanceList = InitList;

                byNameTable.Add(featureName, NewName);
            }
        }
        private void CheckIfFeatureListed(ISealableDictionary <ICompiledFeature, IList <InstanceNameInfo> > byFeatureTable, AncestorFeatureInfo featureInfo, IFeatureName featureName, IFeatureInstance featureInstance)
        {
            bool FeatureAlreadyListed = false;

            foreach (KeyValuePair <ICompiledFeature, IList <InstanceNameInfo> > ImportedEntry in byFeatureTable)
            {
                ICompiledFeature         ImportedKey = ImportedEntry.Key;
                IList <InstanceNameInfo> NameList    = ImportedEntry.Value;

                // Feature already listed
                if (featureInstance.Feature == ImportedKey)
                {
                    UpdateNameList(featureInfo, featureName, featureInstance, NameList);
                    FeatureAlreadyListed = true;
                    break;
                }
            }
            if (!FeatureAlreadyListed)
            {
                IList <InstanceNameInfo> InitList = new List <InstanceNameInfo>();
                InstanceNameInfo         NewInfo  = new InstanceNameInfo(featureInfo, featureInstance, featureName);
                InitList.Add(NewInfo);

                byFeatureTable.Add(featureInstance.Feature, InitList);
            }
        }