当前位置: 首页>>代码示例>>C#>>正文


C# EditingContext.GetEFArtifactService方法代码示例

本文整理汇总了C#中Microsoft.Data.Entity.Design.Base.Context.EditingContext.GetEFArtifactService方法的典型用法代码示例。如果您正苦于以下问题:C# EditingContext.GetEFArtifactService方法的具体用法?C# EditingContext.GetEFArtifactService怎么用?C# EditingContext.GetEFArtifactService使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.Data.Entity.Design.Base.Context.EditingContext的用法示例。


在下文中一共展示了EditingContext.GetEFArtifactService方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateViewModel

        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);
        }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:56,代码来源:EntityDesignExplorerViewModelHelper.cs

示例2: GetArtifact

 internal static EFArtifact GetArtifact(EditingContext context)
 {
     if (context != null)
     {
         var service = context.GetEFArtifactService();
         if (service != null)
         {
             return service.Artifact;
         }
     }
     return null;
 }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:12,代码来源:EditingContextManager.cs

示例3: PropertyExtensionContextImpl

        internal PropertyExtensionContextImpl(
            EditingContext editingContext, ProjectItem projectItem, Version targetSchemaVersion, byte[] extensionToken)
        {
            Debug.Assert(editingContext != null, "editingContext should not be null");
            Debug.Assert(editingContext.GetEFArtifactService().Artifact != null, "editingContext should not have null artifact");
            Debug.Assert(projectItem != null, "projectItem should not be null");
            Debug.Assert(extensionToken != null, "extensionToken should not be null");

            _editingContext = editingContext;
            _projectItem = projectItem;
            _targetSchemaVersion = targetSchemaVersion;
            _extensionToken = extensionToken;
        }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:13,代码来源:PropertyExtensionContextImpl.cs

示例4: GetModelToBrowserModelXRef

        internal static ModelToExplorerModelXRef GetModelToBrowserModelXRef(EditingContext context)
        {
            Type modelToExplorerModelXRefType;
            if (
                !_modelManagerType2XRefType.TryGetValue(
                    context.GetEFArtifactService().Artifact.ModelManager.GetType(), out modelToExplorerModelXRefType))
            {
                Debug.Fail(
                    "Could not find a ModelToExplorerModelXRef type for the ModelManager of type '"
                    + context.GetEFArtifactService().Artifact.ModelManager.GetType()
                    + "'.  Make sure to call AddModelManager2XRefType before calling GetModelToBrowserModelXRef.");
                return null;
            }

            // Update EFElement to BrowserEFElement cross reference so that Search Results can later access it
            var xref = (ModelToExplorerModelXRef)context.Items.GetValue(modelToExplorerModelXRefType);
            if (xref == null)
            {
                xref = (ModelToExplorerModelXRef)Activator.CreateInstance(modelToExplorerModelXRefType);
                context.Items.SetValue(xref);
            }
            return xref;
        }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:23,代码来源:ModelToExplorerModelXRef.cs

示例5: GetCurrentArtifactsInView

        /// <summary>
        ///     Returns the current active artifacts.
        ///     Assumption in here is that a view can span multiple artifacts..
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        protected virtual HashSet<EFArtifact> GetCurrentArtifactsInView(EditingContext context)
        {
            var serviceFromContext = context.GetEFArtifactService();
            Debug.Assert(
                serviceFromContext != null, "Null service in EditingContext for ExplorerViewModelHelper.ProcessModelChangesCommitted()");

            var artifacts = new HashSet<EFArtifact>();
            artifacts.Add(serviceFromContext.Artifact);

            return artifacts;
        }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:17,代码来源:ExplorerViewModelHelper.cs

示例6: GetCurrentArtifactsInView

        protected override HashSet<EFArtifact> GetCurrentArtifactsInView(EditingContext context)
        {
            var artifacts = new HashSet<EFArtifact>();
            var service = context.GetEFArtifactService();
            var entityDesignArtifact = service.Artifact as EntityDesignArtifact;

            Debug.Assert(
                entityDesignArtifact != null,
                "The active artifact is not type of: " + typeof(EntityDesignArtifact) + ", Actual:" + service.Artifact.GetType());
            if (entityDesignArtifact != null)
            {
                artifacts.Add(entityDesignArtifact);

                if (entityDesignArtifact.DiagramArtifact != null)
                {
                    artifacts.Add(entityDesignArtifact.DiagramArtifact);
                }
            }
            return artifacts;
        }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:20,代码来源:EntityDesignExplorerViewModelHelper.cs

示例7: GetDocData

        private static MicrosoftDataEntityDesignDocData GetDocData(EditingContext editingContext)
        {
            Debug.Assert(editingContext != null, "editingContext != null");

            var artifactService = editingContext.GetEFArtifactService();
            return (MicrosoftDataEntityDesignDocData)VSHelpers.GetDocData(ServiceProvider, artifactService.Artifact.Uri.LocalPath);
        }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:7,代码来源:EntityTypeShapeColorTest.cs

示例8: CreateDefaultDiagram

        internal static void CreateDefaultDiagram(EditingContext context, EntityDesignerDiagram diagram)
        {
            var service = context.GetEFArtifactService();
            var artifact = service.Artifact;
            Debug.Assert(artifact != null, "Artifact is null");

            var cpc = new CommandProcessorContext(
                context, EfiTransactionOriginator.EntityDesignerOriginatorId, EntityDesignerResources.Tx_CreateDiagram);
            var cmd = new DelegateCommand(
                () =>
                    {
                        EntityDesignerDiagramAdd.StaticInvoke(cpc, diagram);

                        foreach (var shapeElement in diagram.NestedChildShapes)
                        {
                            var entityShape = shapeElement as EntityTypeShape;
                            if (entityShape != null)
                            {
                                EntityTypeShapeAdd.StaticInvoke(cpc, entityShape);
                                EntityTypeShapeChange.StaticInvoke(
                                    cpc, entityShape, ViewModelDiagram.NodeShape.AbsoluteBoundsDomainPropertyId);
                                EntityTypeShapeChange.StaticInvoke(cpc, entityShape, ViewModelDiagram.NodeShape.IsExpandedDomainPropertyId);
                                continue;
                            }

                            var associationConnector = shapeElement as AssociationConnector;
                            if (associationConnector != null)
                            {
                                AssociationConnectorAdd.StaticInvoke(cpc, associationConnector);
                                AssociationConnectorChange.StaticInvoke(
                                    cpc, associationConnector, ViewModelDiagram.LinkShape.EdgePointsDomainPropertyId);
                                AssociationConnectorChange.StaticInvoke(
                                    cpc, associationConnector, ViewModelDiagram.LinkShape.ManuallyRoutedDomainPropertyId);
                                continue;
                            }

                            var inheritanceConnector = shapeElement as InheritanceConnector;
                            if (inheritanceConnector != null)
                            {
                                InheritanceConnectorAdd.StaticInvoke(cpc, inheritanceConnector);
                                InheritanceConnectorChange.StaticInvoke(
                                    cpc, inheritanceConnector, ViewModelDiagram.LinkShape.EdgePointsDomainPropertyId);
                                InheritanceConnectorChange.StaticInvoke(
                                    cpc, inheritanceConnector, ViewModelDiagram.LinkShape.ManuallyRoutedDomainPropertyId);
                                continue;
                            }
                        }
                    });
            CommandProcessor.InvokeSingleCommand(cpc, cmd);
        }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:50,代码来源:EntityModelToDslModelTranslatorStrategy.cs

示例9: AddNewEnumType

        // <summary>
        //     Show the dialog to create a new enum type.
        // </summary>
        public static EnumType AddNewEnumType(
            string selectedUnderlyingType, EditingContext editingContext, string originatingId, EventHandler onDialogActivated = null)
        {
            if (editingContext == null)
            {
                throw new ArgumentNullException("editingContext");
            }

            var artifactService = editingContext.GetEFArtifactService();
            var entityDesignArtifact = artifactService.Artifact as EntityDesignArtifact;

            Debug.Assert(
                entityDesignArtifact != null,
                typeof(EntityDesignViewModelHelper).Name
                + ".AddEnumType: Unable to find Entity Design Artifact from the passed in editing context.");

            if (entityDesignArtifact != null)
            {
                var vm = new EnumTypeViewModel(entityDesignArtifact, selectedUnderlyingType);

                var result = ShowEnumTypeDialog(vm, onDialogActivated);

                if (result == true
                    && vm.IsValid)
                {
                    var cp = new CommandProcessor(editingContext, originatingId, Resources.Tx_CreateEnumType);
                    var createEnumTypeCommand = new CreateEnumTypeCommand(
                        vm.Name, vm.SelectedUnderlyingType
                        , (vm.IsReferenceExternalType ? vm.ExternalTypeName : String.Empty), vm.IsFlag, false);

                    cp.EnqueueCommand(createEnumTypeCommand);

                    foreach (var member in vm.Members)
                    {
                        if (String.IsNullOrWhiteSpace(member.Name) == false)
                        {
                            cp.EnqueueCommand(new CreateEnumTypeMemberCommand(createEnumTypeCommand, member.Name, member.Value));
                        }
                    }
                    cp.Invoke();
                    return createEnumTypeCommand.EnumType;
                }
            }
            return null;
        }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:48,代码来源:EntityDesignViewModelHelper.cs


注:本文中的Microsoft.Data.Entity.Design.Base.Context.EditingContext.GetEFArtifactService方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。