예제 #1
0
        public List <EvolutionChange> Translate(PSMDiagram diagramOldVersion, PSMDiagram diagramNewVersion)
        {
            ChangesDetectorContext context = new ChangesDetectorContext
            {
                NewVersion = diagramNewVersion.Version,
                OldVersion = diagramOldVersion.Version,
                Diagram    = diagramNewVersion
            };

            Diagram = diagramNewVersion;

            context.ScopeStack.Push(EChangeScope.Diagram);
            ChangesLookupManager.DetectLocalChanges(context);

            foreach (PSMClass rootClass in diagramNewVersion.Roots)
            {
                TranslateClass(rootClass, context);
            }

            EChangeScope pop = context.ScopeStack.Pop();

            Debug.Assert(pop == EChangeScope.Diagram);

            EvolutionChangeSet set = new EvolutionChangeSet(context.Diagram, context.DetectedChanges, diagramOldVersion.Version, diagramNewVersion.Version);

            set.Verify();
            return(context.DetectedChanges);
        }
예제 #2
0
        private static void TranslateAttribute(PSMAttribute psmAttribute, ChangesDetectorContext context)
        {
            context.ScopeStack.Push(EChangeScope.Attribute);
            context.CurrentPSMElement = psmAttribute;

            ChangesLookupManager.DetectLocalChanges(context);

            EChangeScope pop = context.ScopeStack.Pop();

            Debug.Assert(pop == EChangeScope.Attribute);
        }
예제 #3
0
        protected override void TranslateContentChoice(PSMContentChoice contentChoice, ChangesDetectorContext context)
        {
            context.ScopeStack.Push(EChangeScope.ContentChoice);
            context.CurrentPSMElement = contentChoice;

            ChangesLookupManager.DetectLocalChanges(context);
            TranslateComponents(contentChoice, context);

            EChangeScope pop = context.ScopeStack.Pop();

            Debug.Assert(pop == EChangeScope.ContentChoice);
        }
예제 #4
0
        protected override void TranslateAttributeContainer(PSMAttributeContainer attributeContainer, ChangesDetectorContext context)
        {
            context.ScopeStack.Push(EChangeScope.AttributeContainer);
            context.CurrentPSMElement = attributeContainer;

            ChangesLookupManager.DetectLocalChanges(context);
            TranslateAttributes(attributeContainer, context);

            EChangeScope pop = context.ScopeStack.Pop();

            Debug.Assert(pop == EChangeScope.AttributeContainer);
        }
예제 #5
0
        protected override void TranslateAssociation(PSMAssociation association, ChangesDetectorContext context)
        {
            context.ScopeStack.Push(EChangeScope.Association);
            context.CurrentPSMElement = association;

            ChangesLookupManager.DetectLocalChanges(context);
            TranslateAssociationChild(association.Child, context);

            EChangeScope pop = context.ScopeStack.Pop();

            Debug.Assert(pop == EChangeScope.Association);
        }
예제 #6
0
        private void TranslateClassUnion(PSMClassUnion classUnion, ChangesDetectorContext context)
        {
            context.ScopeStack.Push(EChangeScope.ClassUnion);
            context.CurrentPSMElement = classUnion;

            ChangesLookupManager.DetectLocalChanges(context);

            foreach (PSMAssociationChild psmAssociationChild in classUnion.Components)
            {
                TranslateAssociationChild(psmAssociationChild, context);
            }

            EChangeScope pcu = context.ScopeStack.Pop();

            Debug.Assert(pcu == EChangeScope.ClassUnion);
        }
예제 #7
0
        protected override string TranslateClass(PSMClass psmClass, ChangesDetectorContext context)
        {
            context.ScopeStack.Push(EChangeScope.Class);
            context.CurrentPSMElement = psmClass;

            ChangesLookupManager.DetectLocalChanges(context);

            TranslateAttributes(psmClass, context);

            TranslateComponents(psmClass, context);

            EChangeScope pop = context.ScopeStack.Pop();

            Debug.Assert(pop == EChangeScope.Class);

            return(string.Empty);
        }
예제 #8
0
        public void Verify()
        {
            this.Categorize();

            foreach (EvolutionChange evolutionChange in this)
            {
                evolutionChange.Verify();
                if (!ChangesLookupManager.MayRequireRevalidation(evolutionChange))
                {
                    Debug.Assert(!evolutionChange.InvalidatesAttributes);
                    Debug.Assert(!evolutionChange.InvalidatesContent);
                }
            }

            foreach (KeyValuePair <PSMElement, List <EvolutionChange> > kvp in this.changesByTarget)
            {
                List <EvolutionChange> changes = kvp.Value;
                int ca = changes.Count(c => c.Element == kvp.Key && c.EditType == EEditType.Addition);
                int cm = changes.Count(c => c.Element == kvp.Key && c.EditType == EEditType.Migratory);
                int cr = changes.Count(c => c.Element == kvp.Key && c.EditType == EEditType.Removal);
                Debug.Assert(ca + cr <= 1);
                Debug.Assert(cm == 0 || ca + cr == 0);
            }
        }
예제 #9
0
 private void RemoveChangesNotRequiringRevalidation()
 {
     this.Where(c => !ChangesLookupManager.MayRequireRevalidation(c)).ToList();
     this.RemoveAll(c => !ChangesLookupManager.MayRequireRevalidation(c));
 }