src/Misc/EFTools/EntityDesignPackage/CustomCode/MicrosoftDataEntityDesignDocView.cs
/// <summary>
///     Helper method to retrieve/create DSL Diagram for the view.
/// </summary>
Helper method to retrieve/create DSL Diagram for the view.
Helper method to retrieve / create DSL Diagram for the view .
[SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope")]
        private EntityDesignerDiagram GetNewOrExistingViewDiagram()
        {
            EntityDesignerDiagram diagram = null;
            var docData = DocData as MicrosoftDataEntityDesignDocDataBase;
            diagram = GetExistingViewDiagram(docData, _diagramId);
            if (diagram == null
                && String.IsNullOrEmpty(_diagramId) == false)
            {
                var artifact = Context.GetEFArtifactService().Artifact as EntityDesignArtifact;
                Debug.Assert(artifact != null, "Could not find instance of EntityDesignArtifact in EditingContext.");
                if (artifact != null)
                {
                    if (artifact.IsDesignerSafe
                        && artifact.DesignerInfo != null
                        && artifact.DesignerInfo.Diagrams != null)
                    {
                        var modelDiagram = artifact.DesignerInfo.Diagrams.GetDiagram(_diagramId);
                        if (modelDiagram != null)
                        {
                            using (var transaction = docData.Store.TransactionManager.BeginTransaction("OpenView", true))
                            {
                                var evm =
                                    ModelTranslatorContextItem.GetEntityModelTranslator(Context)
                                        .TranslateModelToDslModel(modelDiagram, new DslModeling.Partition(docData.Store)) as
                                    EntityDesignerViewModel;
                                diagram = CreateDslDiagram(evm);
                                transaction.Commit();
                            }
                        }
                    }
                    else
                    {
                        using (var transaction = docData.Store.TransactionManager.BeginTransaction("OpenView", true))
                        {
                            var evm =
                                ModelTranslatorContextItem.GetEntityModelTranslator(Context)
                                    .TranslateModelToDslModel(null, new DslModeling.Partition(docData.Store)) as EntityDesignerViewModel;
                            diagram = CreateDslDiagram(evm);
                            transaction.Commit();
                        }
                    }
                }
            }
            return diagram;
        }
[ SuppressMessage ( " " , " " ) ] private EntityDesignerDiagram GetNewOrExistingViewDiagram ( ) { EntityDesignerDiagram diagram = null ; var docData = DocData as MicrosoftDataEntityDesignDocDataBase ; diagram = GetExistingViewDiagram ( docData , _diagramId ) ; if ( diagram == null && String . IsNullOrEmpty ( _diagramId ) == false ) { var artifact = Context . GetEFArtifactService ( ) . Artifact as EntityDesignArtifact ; Debug . Assert ( artifact != null , " " ) ; if ( artifact != null ) { if ( artifact . IsDesignerSafe && artifact . DesignerInfo != null && artifact . DesignerInfo . Diagrams != null ) { var modelDiagram = artifact . DesignerInfo . Diagrams . GetDiagram ( _diagramId ) ; if ( modelDiagram != null ) { using ( var transaction = docData . Store . TransactionManager . BeginTransaction ( " " , true ) ) { var evm = ModelTranslatorContextItem . GetEntityModelTranslator ( Context ) . TranslateModelToDslModel ( modelDiagram , new DslModeling . Partition ( docData . Store ) ) as EntityDesignerViewModel ; diagram = CreateDslDiagram ( evm ) ; transaction . Commit ( ) ; } } } else { using ( var transaction = docData . Store . TransactionManager . BeginTransaction ( " " , true ) ) { var evm = ModelTranslatorContextItem . GetEntityModelTranslator ( Context ) . TranslateModelToDslModel ( null , new DslModeling . Partition ( docData . Store ) ) as EntityDesignerViewModel ; diagram = CreateDslDiagram ( evm ) ; transaction . Commit ( ) ; } } } } return diagram ; }
Helper method to retrieve/create DSL Diagram for the view.
Helper method to retrieve / create DSL Diagram for the view .
// Check whether the EntityDesignerDiagram exists. // Create DSL diagram if the diagram has not been created yet. // Get the corresponding model diagram.