コード例 #1
0
        private void LoadAssociationsFromModel()
        {
            // load children from model
            // note: have to go to parent to get this as this is a dummy node
            var entityModel = Parent.ModelItem as BaseEntityModel;

            if (entityModel != null)
            {
                foreach (var child in entityModel.Associations())
                {
                    if (child.EntityModel.IsCSDL)
                    {
                        _associations.Insert(
                            (ExplorerConceptualAssociation)
                            ModelToExplorerModelXRef.GetNewOrExisting(_context, child, this, typeof(ExplorerConceptualAssociation)));
                    }
                    else
                    {
                        _associations.Insert(
                            (ExplorerStorageAssociation)
                            ModelToExplorerModelXRef.GetNewOrExisting(_context, child, this, typeof(ExplorerStorageAssociation)));
                    }
                }
            }
        }
コード例 #2
0
ファイル: ExplorerEntityType.cs プロジェクト: dotnet/ef6tools
        private void LoadPropertiesFromModel()
        {
            // load Properties from model
            var entityType = ModelItem as EntityType;

            Debug.Assert(
                entityType != null, "Underlying EntityType is null calculating Properties for ExplorerEntityType with name " + Name);
            if (entityType != null)
            {
                foreach (var child in entityType.Properties())
                {
                    if (child.EntityModel.IsCSDL)
                    {
                        _properties.Insert(
                            (ExplorerConceptualProperty)
                            ModelToExplorerModelXRef.GetNewOrExisting(_context, child, this, typeof(ExplorerConceptualProperty)));
                    }
                    else
                    {
                        _properties.Insert(
                            (ExplorerStorageProperty)
                            ModelToExplorerModelXRef.GetNewOrExisting(_context, child, this, typeof(ExplorerStorageProperty)));
                    }
                }
            }
        }
コード例 #3
0
        private void LoadEntityTypesFromModel()
        {
            // load children from model
            // note: have to go to parent to get this as this is a dummy node
            var entityModel = Parent.ModelItem as BaseEntityModel;

            if (entityModel != null)
            {
                foreach (var child in entityModel.EntityTypes())
                {
                    if (_isConceptual)
                    {
                        _entityTypes.Insert(
                            (ExplorerConceptualEntityType)
                            ModelToExplorerModelXRef.GetNewOrExisting(_context, child, this, typeof(ExplorerConceptualEntityType)));
                    }
                    else
                    {
                        _entityTypes.Insert(
                            (ExplorerStorageEntityType)
                            ModelToExplorerModelXRef.GetNewOrExisting(_context, child, this, typeof(ExplorerStorageEntityType)));
                    }
                }
            }
        }
コード例 #4
0
        public override void CreateViewModel(EditingContext ctx)
        {
            var service = ctx.GetEFArtifactService();

            Debug.Assert(service != null, "Null service in ExplorerViewModelHelper.CreateViewModel()");
            var artifact = service.Artifact;

            Debug.Assert(artifact != null, "Null artifact in ExplorerViewModelHelper.CreateViewModel()");

            var xref = ModelToExplorerModelXRef.GetModelToBrowserModelXRef(ctx);

            xref.Clear();

            var edmRootNode = new ExplorerRootNode(ctx, null, artifact.Uri);

            var designerInfo = artifact.DesignerInfo();

            if (designerInfo != null &&
                designerInfo.Diagrams != null)
            {
                var explorerDiagrams = (ExplorerDiagrams)
                                       ModelToExplorerModelXRef.GetNewOrExisting(
                    ctx, designerInfo.Diagrams, edmRootNode, typeof(ExplorerDiagrams));
                edmRootNode.Diagrams = explorerDiagrams;
            }

            if (artifact.ConceptualModel() != null)
            {
                var browserCsdlEntityModel = (ExplorerConceptualEntityModel)
                                             ModelToExplorerModelXRef.GetNewOrExisting(
                    ctx, artifact.ConceptualModel(), edmRootNode, typeof(ExplorerConceptualEntityModel));
                edmRootNode.ConceptualModel = browserCsdlEntityModel;
            }

            if (artifact.StorageModel() != null)
            {
                var browserSsdlEntityModel = (ExplorerStorageEntityModel)
                                             ModelToExplorerModelXRef.GetNewOrExisting(
                    ctx, artifact.StorageModel(), edmRootNode, typeof(ExplorerStorageEntityModel));
                edmRootNode.StorageModel = browserSsdlEntityModel;
            }

            // expand the tree view so that the Conceptual, Storage Models, and Diagram nodes are visible
            if (edmRootNode.Diagrams != null)
            {
                edmRootNode.Diagrams.Types.ExpandTreeViewToMe();
            }

            if (edmRootNode.ConceptualModel != null)
            {
                edmRootNode.ConceptualModel.Types.ExpandTreeViewToMe();
            }

            if (edmRootNode.StorageModel != null)
            {
                edmRootNode.StorageModel.Types.ExpandTreeViewToMe();
            }

            base.ViewModel = new ExplorerViewModel(ctx, edmRootNode);
        }
コード例 #5
0
ファイル: ExplorerDiagrams.cs プロジェクト: dotnet/ef6tools
        private void LoadDiagramsFromModel()
        {
            // load children from model
            var diagrams = ModelItem as Diagrams;

            if (diagrams != null)
            {
                foreach (var child in diagrams.Items)
                {
                    _diagrams.Insert(
                        (ExplorerDiagram)ModelToExplorerModelXRef.GetNewOrExisting(_context, child, this, typeof(ExplorerDiagram)));
                }
            }
        }
コード例 #6
0
        private void LoadEntityContainersFromModel()
        {
            // load entity container children from model
            var em = ModelItem as ConceptualEntityModel;

            if (em != null)
            {
                foreach (ConceptualEntityContainer child in em.EntityContainers())
                {
                    _entityContainers.Insert(
                        (ExplorerConceptualEntityContainer)
                        ModelToExplorerModelXRef.GetNewOrExisting(_context, child, this, typeof(ExplorerConceptualEntityContainer)));
                }
            }
        }
コード例 #7
0
        protected override void InsertChild(EFElement efElementToInsert)
        {
            var entityContainer = efElementToInsert as ConceptualEntityContainer;

            if (entityContainer != null)
            {
                _entityContainers.Insert(
                    (ExplorerConceptualEntityContainer)
                    ModelToExplorerModelXRef.GetNewOrExisting(_context, entityContainer, this, typeof(ExplorerConceptualEntityContainer)));
            }
            else
            {
                base.InsertChild(efElementToInsert);
            }
        }
        private void LoadAssociationSetsFromModel()
        {
            // load children from model
            // note: have to go to parent to get this as this is a dummy node
            var container = Parent.ModelItem as BaseEntityContainer;

            if (container != null)
            {
                foreach (var child in container.AssociationSets())
                {
                    _associationSets.Insert(
                        (ExplorerAssociationSet)
                        ModelToExplorerModelXRef.GetNewOrExisting(_context, child, this, typeof(ExplorerAssociationSet)));
                }
            }
        }
コード例 #9
0
        private void LoadParametersFromModel()
        {
            // load children from model
            var functionImport = ModelItem as FunctionImport;

            Debug.Assert(functionImport != null, "Underlying FunctionImport is null for ExplorerFunctionImport with name " + Name);
            if (functionImport != null)
            {
                foreach (var child in functionImport.Parameters())
                {
                    _parameters.Insert(
                        (ExplorerParameter)
                        ModelToExplorerModelXRef.GetNewOrExisting(_context, child, this, typeof(ExplorerParameter)));
                }
            }
        }
コード例 #10
0
        private void LoadFunctionsFromModel()
        {
            // load children from model
            // note: have to go to parent to get this as this is a dummy node
            var sem = Parent.ModelItem as StorageEntityModel;

            Debug.Assert(sem != null, "BrowserFunctions node should always have a StorageEntityModel as this.Parent.ModelItem");
            if (sem != null)
            {
                foreach (var child in sem.Functions())
                {
                    _functions.Insert(
                        (ExplorerFunction)
                        ModelToExplorerModelXRef.GetNewOrExisting(_context, child, this, typeof(ExplorerFunction)));
                }
            }
        }
コード例 #11
0
        private void LoadPropertiesFromModel()
        {
            // load Properties from model
            var complexType = ModelItem as ComplexType;

            Debug.Assert(
                complexType != null, "Underlying ComplexType is null calculating Properties for ExplorerComplexType with name " + Name);
            if (complexType != null)
            {
                foreach (var child in complexType.Properties())
                {
                    _properties.Insert(
                        (ExplorerConceptualProperty)
                        ModelToExplorerModelXRef.GetNewOrExisting(_context, child, this, typeof(ExplorerConceptualProperty)));
                }
            }
        }
コード例 #12
0
        protected override void LoadChildrenFromModel()
        {
            var diagram = ModelItem as Diagram;

            Debug.Assert(diagram != null, "Underlying diagram is null calculating EntityTypeShape for ExplorerDiagram with name " + Name);
            if (diagram != null)
            {
                foreach (var child in diagram.EntityTypeShapes)
                {
                    // only show the EntityTypeShape that contains a valid EntityType.
                    if (child.EntityType.Target != null)
                    {
                        _explorerEntityTypeShapes.Insert(
                            (ExplorerEntityTypeShape)
                            ModelToExplorerModelXRef.GetNewOrExisting(_context, child, this, typeof(ExplorerEntityTypeShape)));
                    }
                }
            }
        }
コード例 #13
0
        private void LoadFunctionImportsFromModel()
        {
            // load children from model
            // note: have to go to parent to get this as this is a dummy node
            var entityModel = Parent.ModelItem as ConceptualEntityModel;

            if (entityModel != null)
            {
                var entityContainer = entityModel.FirstEntityContainer as ConceptualEntityContainer;
                if (entityContainer != null)
                {
                    foreach (var child in entityContainer.FunctionImports())
                    {
                        _functionImports.Insert(
                            (ExplorerFunctionImport)
                            ModelToExplorerModelXRef.GetNewOrExisting(_context, child, this, typeof(ExplorerFunctionImport)));
                    }
                }
            }
        }
コード例 #14
0
ファイル: ExplorerEntityType.cs プロジェクト: dotnet/ef6tools
        private void LoadNavigationPropertiesFromModel()
        {
            // load NavigationProperties from model
            var entityType = ModelItem as EntityType;

            Debug.Assert(
                entityType != null,
                "Underlying EntityType is null calculating NavigationProperties for ExplorerEntityType with name " + Name);
            var cet = entityType as ConceptualEntityType;

            if (cet != null)
            {
                foreach (var child in cet.NavigationProperties())
                {
                    _navigationProperties.Insert(
                        (ExplorerNavigationProperty)
                        ModelToExplorerModelXRef.GetNewOrExisting(_context, child, this, typeof(ExplorerNavigationProperty)));
                }
            }
        }
コード例 #15
0
        internal ExplorerEFElement GetExplorerEFElementForEFObject(EditingContext editingContext, EFObject targetEFObject)
        {
            if (targetEFObject == null)
            {
                return(null);
            }

            //
            //  Find the EFObject we want to navigate to for the given EFObject
            //
            var targetEFElement = GetNavigationTarget(targetEFObject);

            //
            // get all EFElement nodes on the path from our target node to the root.
            //
            var elementStack = new LinkedList <EFElement>();
            var e            = targetEFElement;

            while (e != null)
            {
                elementStack.AddLast(e);
                e = e.Parent as EFElement;
            }

            //
            // unwind the stack, making sure that each element's explorer model node exists.
            //
            var explorerElement = ViewModel.RootNode;

            while (elementStack.Count > 0)
            {
                var e2 = elementStack.Last.Value;
                elementStack.RemoveLast();
                var viewModelType = ModelToExplorerModelXRef.GetViewModelTypeForEFlement(editingContext, e2);
                // if viewModelType is null then that kind of EFElement is not displayed
                // in the Explorer (e.g. S-side StorageEntityContainer and children)
                if (null != viewModelType)
                {
                    var nextElement = ModelToExplorerModelXRef.GetNewOrExisting(editingContext, e2, explorerElement, viewModelType);

                    // There are "dummy-nodes" in the view-model that don't correspond to a node in the model.
                    // We need to skip over them here.
                    if (nextElement != null &&
                        elementStack.Count > 0)
                    {
                        nextElement = nextElement.GetParentNodeForElement(elementStack.Last.Value);
                        Debug.Assert(nextElement != null, "GetParentNodeForElement returned null");
                    }

                    if (nextElement != null)
                    {
                        explorerElement = nextElement;
                    }
                }
            }
            Debug.Assert(explorerElement != null, "no explorer element found for targetEFObject");

            if (explorerElement != null)
            {
                //
                // now make sure that our target node in the explorer tree is visible.
                //
                explorerElement.ExpandTreeViewToMe();
            }

            return(explorerElement);
        }