src/Misc/EFTools/EntityDesignPackage/CustomCode/MicrosoftDataEntityDesignDocView.cs
/// <summary>
///     This uses the XRef in our context to find the Model item that is the basis for
///     each DSL object in the selection collection.  For each Model item, we get the correct
///     item descriptor and create a new selection array of these.
/// </summary>
/// <param name="objects"></param>
/// <returns></returns>
This uses the XRef in our context to find the Model item that is the basis for
each DSL object in the selection collection.  For each Model item, we get the correct
item descriptor and create a new selection array of these.
This uses the XRef in our context to find the Model item that is the basis for each DSL object in the selection collection . For each Model item we get the correct item descriptor and create a new selection array of these .
private ArrayList ConvertDslModelElementArrayToItemDescriptors(object[] objects, bool gettingAllObjects)
        {
            var selectedDesignerObjects = objects;
            var selectedModelObjects = new List<EFObject>();
            var selectedModelObjectDescriptors = new ArrayList();
            foreach (var o in selectedDesignerObjects)
            {
                DslModeling.ModelElement dslElem = null;
                var elemList = o as DslDiagrams.ElementListCompartment;
                var presElem = o as DslDiagrams.PresentationElement;
                if (elemList != null)
                {
                    if (elemList.IsNestedChild
                        && elemList.ParentShape != null)
                    {
                        presElem = elemList.ParentShape;
                        dslElem = presElem.ModelElement;
                    }
                    else
                    {
                        continue;
                    }
                }
                else if (presElem != null)
                {
                    dslElem = presElem.ModelElement;
                }
                else
                {
                    dslElem = o as DslModeling.ModelElement;
                }
                if (dslElem != null)
                {
                    EFObject modelElem;
                    if (dslElem is EntityType
                        && presElem != null)
                    {
                        modelElem = XRef.GetExisting(presElem);
                    }
                    else
                    {
                        modelElem = XRef.GetExisting(dslElem);
                    }
                    if (modelElem != null)
                    {
                        selectedModelObjects.Add(modelElem);
                        selectedModelObjectDescriptors.Add(PropertyWindowViewModel.GetObjectDescriptor(modelElem, Context, true));
                    }
                }
            }
            if (gettingAllObjects == false)
            {
                if (Context != null
                    && Context.Items != null)
                {
                    Context.Items.SetValue(new EntityDesignerSelection(selectedModelObjects));
                }
            }
            return selectedModelObjectDescriptors;
        }
private ArrayList ConvertDslModelElementArrayToItemDescriptors ( object [ ] objects , bool gettingAllObjects ) { var selectedDesignerObjects = objects ; var selectedModelObjects = new List < EFObject > ( ) ; var selectedModelObjectDescriptors = new ArrayList ( ) ; foreach ( var o in selectedDesignerObjects ) { DslModeling . ModelElement dslElem = null ; var elemList = o as DslDiagrams . ElementListCompartment ; var presElem = o as DslDiagrams . PresentationElement ; if ( elemList != null ) { if ( elemList . IsNestedChild && elemList . ParentShape != null ) { presElem = elemList . ParentShape ; dslElem = presElem . ModelElement ; } else { continue ; } } else if ( presElem != null ) { dslElem = presElem . ModelElement ; } else { dslElem = o as DslModeling . ModelElement ; } if ( dslElem != null ) { EFObject modelElem ; if ( dslElem is EntityType && presElem != null ) { modelElem = XRef . GetExisting ( presElem ) ; } else { modelElem = XRef . GetExisting ( dslElem ) ; } if ( modelElem != null ) { selectedModelObjects . Add ( modelElem ) ; selectedModelObjectDescriptors . Add ( PropertyWindowViewModel . GetObjectDescriptor ( modelElem , Context , true ) ) ; } } } if ( gettingAllObjects == false ) { if ( Context != null && Context . Items != null ) { Context . Items . SetValue ( new EntityDesignerSelection ( selectedModelObjects ) ) ; } } return selectedModelObjectDescriptors ; }
This uses the XRef in our context to find the Model item that is the basis for
each DSL object in the selection collection.
This uses the XRef in our context to find the Model item that is the basis for each DSL object in the selection collection .
// save off this reference // create a new array to hold the item descriptors // if the user selects a compartment element, we want to display the entity-type and the shape property. // they have selected one of the compartments, probably wanting to show  // the right-click context menu // if this is a shape, gets it corresponding DSL object // o is a non-shape // there might be no ModelElement corresponding to the selected object // If an EntityType is selected in DSL canvas, we want to show the property of the EntityTypeShape. // model element might not be yet created // update the selection for the Entity Designer in case anyone else is interested
None
objects
object[]
None
gettingAllObjects
bool