private IFeatureInstance MergeCreateNewInstance(IClass item, IFeatureName importedKey, InheritedInstanceInfo importedInstance, out InstanceNameInfo selectedInstanceInfo) { IFeatureInstance NewInstance; if (importedInstance.EffectiveInstance.IsAssigned) { selectedInstanceInfo = importedInstance.EffectiveInstance.Item; } else { IList <InstanceNameInfo> InstancePrecursorList = importedInstance.PrecursorInstanceList; selectedInstanceInfo = null; foreach (InstanceNameInfo Item in InstancePrecursorList) { if (Item.Instance.Owner == item) { selectedInstanceInfo = Item; break; } } if (selectedInstanceInfo == null) { selectedInstanceInfo = InstancePrecursorList[0]; } } NewInstance = new FeatureInstance(selectedInstanceInfo.Instance.Owner, selectedInstanceInfo.Instance.Feature, importedInstance.IsKept, importedInstance.IsDiscontinued); return(NewInstance); }
/// <summary> /// Clones this instance using the specified ancestor. /// </summary> /// <param name="ancestor">The ancestor.</param> public virtual IFeatureInstance Clone(IClassType ancestor) { IPrecursorInstance NewPrecursor = new PrecursorInstance(ancestor, this); Debug.Assert(NewPrecursor.Ancestor == ancestor); IFeatureInstance ClonedObject = new FeatureInstance(Owner, Feature); foreach (IPrecursorInstance PrecursorInstance in PrecursorList) { ClonedObject.PrecursorList.Add(PrecursorInstance); } ClonedObject.PrecursorList.Add(NewPrecursor); ClonedObject.SetIsForgotten(IsForgotten); ClonedObject.SetIsKept(IsKept); ClonedObject.SetIsDiscontinued(IsDiscontinued); ClonedObject.SetInheritBySideAttribute(InheritBySideAttribute); if (OriginalPrecursor.IsAssigned) { ClonedObject.OriginalPrecursor.Item = OriginalPrecursor.Item; } return(ClonedObject); }
/// <summary> /// Applies the rule. /// </summary> /// <param name="node">The node instance to modify.</param> /// <param name="data">Private data from CheckConsistency().</param> public override void Apply(IIndexerFeature node, object data) { IClass EmbeddingClass = node.EmbeddingClass; IFeatureName FeatureEntityName = FeatureName.IndexerFeatureName; IFeatureInstance NewInstance = new FeatureInstance(EmbeddingClass, node); node.ValidFeatureName.Item = FeatureEntityName; EmbeddingClass.LocalFeatureTable.Add(FeatureEntityName, NewInstance); }
/// <summary> /// Applies the rule. /// </summary> /// <param name="node">The node instance to modify.</param> /// <param name="data">Private data from CheckConsistency().</param> public override void Apply(TFeature node, object data) { IClass EmbeddingClass = node.EmbeddingClass; IName EntityName = (IName)node.EntityName; Debug.Assert(EntityName.ValidText.IsAssigned); string ValidText = EntityName.ValidText.Item; IFeatureName FeatureEntityName = new FeatureName(ValidText); IFeatureInstance NewInstance = new FeatureInstance(EmbeddingClass, node); node.ValidFeatureName.Item = FeatureEntityName; EmbeddingClass.LocalFeatureTable.Add(FeatureEntityName, NewInstance); }