src/Misc/EFTools/EntityDesignEntityDesigner/CustomCode/DomainClasses/EntityDesignerViewModel.cs
/// <summary>
///     Project the Diagram Model changes to DSL Model Elements.
///     Note that this is only to ensure that DSL Model Elements are in sync with the diagram model.
/// </summary>
Project the Diagram Model changes to DSL Model Elements.
Note that this is only to ensure that DSL Model Elements are in sync with the diagram model.
Project the Diagram Model changes to DSL Model Elements . Note that this is only to ensure that DSL Model Elements are in sync with the diagram model .
private void ProcessSingleDiagramModelChange(EfiChange change, HashSet<EFObject> extraElementsToProcess)
        {
            var diagramObject = change.Changed as ModelDiagram.BaseDiagramObject;
            var xref = ModelXRef;
            if (diagramObject == null
                || diagramObject.Diagram == null
                || diagramObject.Diagram.Id != DiagramId)
            {
                return;
            }
            if (change.Type == EfiChange.EfiChangeType.Create)
            {
                EFObject efObject = null;
                var entityTypeShape = change.Changed as ModelDesigner.EntityTypeShape;
                var inheritanceConnector = change.Changed as ModelDesigner.InheritanceConnector;
                var associationConnector = change.Changed as ModelDesigner.AssociationConnector;
                if (entityTypeShape != null)
                {
                    Model.Entity.EntityType et = entityTypeShape.EntityType.Target as ConceptualEntityType;
                    if (et != null)
                    {
                        extraElementsToProcess.Add(et);
                        efObject = et;
                    }
                }
                else if (inheritanceConnector != null)
                {
                    var et = inheritanceConnector.EntityType.Target as ConceptualEntityType;
                    if (et != null)
                    {
                        efObject = et.BaseType;
                    }
                }
                else if (associationConnector != null)
                {
                    efObject = associationConnector.Association.Target;
                }
                if (efObject != null)
                {
                    OnEFObjectCreatedOrUpdated(efObject, xref);
                }
            }
            else if (change.Type == EfiChange.EfiChangeType.Delete)
            {
                var entityTypeShape = change.Changed as ModelDesigner.EntityTypeShape;
                var inheritanceConnector = change.Changed as ModelDesigner.InheritanceConnector;
                var associationConnector = change.Changed as ModelDesigner.AssociationConnector;
                EFObject efObject = null;
                if (entityTypeShape != null)
                {
                    efObject = entityTypeShape.EntityType.Target;
                }
                else if (inheritanceConnector != null)
                {
                    var et = inheritanceConnector.EntityType.Target as ConceptualEntityType;
                    if (et != null)
                    {
                        efObject = et.BaseType;
                    }
                }
                else if (associationConnector != null)
                {
                    efObject = associationConnector.Association.Target;
                }
                if (efObject != null)
                {
                    OnEFObjectDeleted(efObject, xref);
                }
            }
        }
private void ProcessSingleDiagramModelChange ( EfiChange change , HashSet < EFObject > extraElementsToProcess ) { var diagramObject = change . Changed as ModelDiagram . BaseDiagramObject ; var xref = ModelXRef ; if ( diagramObject == null || diagramObject . Diagram == null || diagramObject . Diagram . Id != DiagramId ) { return ; } if ( change . Type == EfiChange . EfiChangeType . Create ) { EFObject efObject = null ; var entityTypeShape = change . Changed as ModelDesigner . EntityTypeShape ; var inheritanceConnector = change . Changed as ModelDesigner . InheritanceConnector ; var associationConnector = change . Changed as ModelDesigner . AssociationConnector ; if ( entityTypeShape != null ) { Model . Entity . EntityType et = entityTypeShape . EntityType . Target as ConceptualEntityType ; if ( et != null ) { extraElementsToProcess . Add ( et ) ; efObject = et ; } } else if ( inheritanceConnector != null ) { var et = inheritanceConnector . EntityType . Target as ConceptualEntityType ; if ( et != null ) { efObject = et . BaseType ; } } else if ( associationConnector != null ) { efObject = associationConnector . Association . Target ; } if ( efObject != null ) { OnEFObjectCreatedOrUpdated ( efObject , xref ) ; } } else if ( change . Type == EfiChange . EfiChangeType . Delete ) { var entityTypeShape = change . Changed as ModelDesigner . EntityTypeShape ; var inheritanceConnector = change . Changed as ModelDesigner . InheritanceConnector ; var associationConnector = change . Changed as ModelDesigner . AssociationConnector ; EFObject efObject = null ; if ( entityTypeShape != null ) { efObject = entityTypeShape . EntityType . Target ; } else if ( inheritanceConnector != null ) { var et = inheritanceConnector . EntityType . Target as ConceptualEntityType ; if ( et != null ) { efObject = et . BaseType ; } } else if ( associationConnector != null ) { efObject = associationConnector . Association . Target ; } if ( efObject != null ) { OnEFObjectDeleted ( efObject , xref ) ; } } }
Project the Diagram Model changes to DSL Model Elements.
Project the Diagram Model changes to DSL Model Elements .
// Ignore if the change is not model diagram object or diagram object does not below to this view model diagram. // There is a code above that will Debug.Fail if the object in extraElementsToProcess is not ConceptualEntityType
change
EfiChange
extraElementsToProcess
HashSet<EFObject>