src/Misc/EFTools/EntityDesignEntityDesigner/CustomCode/DomainClasses/DomainClassExtension.cs
/// <summary>
///     Return DSL root view model for the given model element.
///     In multiple diagram world, each diagram will have a root view model.
/// </summary>
/// <param name="modelElement"></param>
/// <returns></returns>
Return DSL root view model for the given model element.
In multiple diagram world, each diagram will have a root view model.
Return DSL root view model for the given model element . In multiple diagram world each diagram will have a root view model .
internal static EntityDesignerViewModel GetRootViewModel(this ModelElement modelElement)
        {
            var shapeElement = modelElement as ShapeElement;
            if (shapeElement != null)
            {
                Debug.Assert(
                    shapeElement.Diagram != null,
                    "ShapeElement's Diagram should never be null. Element name: " + shapeElement.AccessibleName + ", type: "
                    + shapeElement.GetType().Name);
                if (shapeElement.Diagram != null)
                {
                    return shapeElement.Diagram.ModelElement as EntityDesignerViewModel;
                }
            }
            else
            {
                Debug.Assert(modelElement.Partition != null, "ModelElement's Partition should never be null.");
                if (modelElement.Partition != null)
                {
                    Debug.Assert(modelElement.Partition.ElementDirectory != null, "Why ModelElement Partition's ElementDirectory is null?");
                    if (modelElement.Partition.ElementDirectory != null)
                    {
                        return modelElement.Partition.ElementDirectory.FindElements<EntityDesignerViewModel>().FirstOrDefault();
                    }
                }
            }
            return null;
        }
internal static EntityDesignerViewModel GetRootViewModel ( this ModelElement modelElement ) { var shapeElement = modelElement as ShapeElement ; if ( shapeElement != null ) { Debug . Assert ( shapeElement . Diagram != null , " " + shapeElement . AccessibleName + " " + shapeElement . GetType ( ) . Name ) ; if ( shapeElement . Diagram != null ) { return shapeElement . Diagram . ModelElement as EntityDesignerViewModel ; } } else { Debug . Assert ( modelElement . Partition != null , " " ) ; if ( modelElement . Partition != null ) { Debug . Assert ( modelElement . Partition . ElementDirectory != null , " " ) ; if ( modelElement . Partition . ElementDirectory != null ) { return modelElement . Partition . ElementDirectory . FindElements < EntityDesignerViewModel > ( ) . FirstOrDefault ( ) ; } } } return null ; }
Return DSL root view model for the given model element.
Return DSL root view model for the given model element .
// if model element is a shape element, we should be able to find root view model from the shape element's diagram.
None
ModelElement
this
modelElement
None