如何扩展ADO.NET实体设计器?

发布于 2024-07-15 23:43:25 字数 105 浏览 8 评论 0原文

有谁知道如何扩展(即向 Visual Studio 中的实体设计器添加功能)吗?

例如,我想右键单击设计器上实体的属性,并在上下文菜单上有一个新选项,允许我做任何我想做的事情。

Does anyonw know how to extend, i.e., add funcionalities to the Entity Designer in Visual Studio?

For instance, I want to right click a property of an entity on the designer and have a new option on the context-menu that allows me to do any stuff I want.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

爱已欠费 2024-07-22 23:43:25

VS 2008 SP1 中的实体设计器没有太多可扩展性挂钩。 您可以做的是利用 Visual Studio 扩展性(VSIP,现在称为 VSX):

  1. 添加 您自己的上下文菜单
  2. 使用IVsMonitorSelection 获取当前选择,从中可以获取 ISelectionContainer。
  3. 如果用户已选择图表表面,则可以将 ISelectionContainer 转换为 DiagramDocView。 这是“DSL”的一部分,“DSL”是实体设计器用于其设计器界面的框架。
  4. 从这里您可以在DiagramDocView 中执行许多操作。 DiagramDocView.CurrentDiagram 将为您提供图表对象。 您可以调用Diagram.NestedChildShapes来获取图中的所有形状。 要更改图表,您必须创建 DSL 事务并对事务中的形状进行编辑。 这只是实体设计器之上的另一个级别,所有内容都将得到正确处理:

    using (Transaction tx = store.TransactionManager.BeginTransaction(txText)) 
      { 
         // 做一些事情,例如创建 EntityTypeShape; 
         tx.Commit(); 
      } 
      

VS 2010 中的实体设计器将具有更多的可扩展性挂钩,允许您通过属性窗口或向导影响模型。 新的“模型优先”功能中的新可扩展性基本上允许您以可组合的方式从 Visual Studio 中的模型生成任何内容。

The Entity Designer in VS 2008 SP1 doesn't have many extensibility hooks. What you could do is leverage the Visual Studio extensibility (VSIP, now known as VSX):

  1. Add in your own context menu
  2. Use IVsMonitorSelection to get the current selection, from which you can get ISelectionContainer.
  3. If the user has selected the diagram surface, you can then cast ISelectionContainer as DiagramDocView. This is part of 'DSL', which is the framework that the Entity Designer uses for its designer surface.
  4. From here you can do lots of things within the DiagramDocView. DiagramDocView.CurrentDiagram will give you the Diagram object. You can call Diagram.NestedChildShapes to get all shapes in the diagram. To make changes to the diagram, you will have to create a DSL transaction and perform your edits to the shapes in the transaction. This is simply another level above the Entity Designer and everything will be handled correctly:

    using (Transaction tx = store.TransactionManager.BeginTransaction(txText))
    {
       // do something, such as creating an EntityTypeShape;
       tx.Commit();
    }
    

The Entity Designer in VS 2010 will have a lot more extensibility hooks to allow you to influence the model through the property window or through the wizard. New extensibility work in the new 'Model First' feature will basically allow you to generate anything from a model within Visual Studio in a composable way.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文