zoukankan      html  css  js  c++  java
  • XSD To Entity Vs2008 Add Ins

    最近闲得无事,不过也是为了以后设计的一个环节,做了一个Add-Ins

    主要是XSD To Entity的操作。

    Step 1:先配置一下

               把相关的AddIn、DLL Copy To 当前用户\文档\Visual Studio 200X\Addins

    image

    Step 2:Tools\Add-In Manager勾选即可

    image

    Step 3:现在随便打开一个project,然后在Code Windows中右击,就可以看到XSD To Entity

    1

    界面

    image

    选择一个XSD File

    image

    转换完成

    image

    转换文件

    image 

    代码方面:

    image

    Connect.cs:

     1 public void OnConnection(object application, ext_ConnectMode connectMode, object addInInst, ref Array custom)
     2 {
     3           _applicationObject = (DTE2)application;
     4           _addInInstance = (AddIn)addInInst;
     5 
     6           // Get the CommandBar for the window in which you want to add the menuitem.
     7           //I am going to add it to the code window.
     8           CommandBar oCommandBar = ((CommandBars)_applicationObject.CommandBars)["Code Window"];
     9 
    10           // I am going to add a MenuItem and a submenuitem to that.
    11           // So I go ahead and create a PopUp Item.
    12           CommandBarPopup oPopup = (CommandBarPopup)oCommandBar.Controls.Add(MsoControlType.msoControlPopup,
    13                                                                              System.Reflection.Missing.Value,
    14                                                                              System.Reflection.Missing.Value, 1true);
    15           // Set the caption of the menuitem
    16           oPopup.Caption = "XSD To Entity";
    17 
    18           // Now I go ahead and add a Submenu item to the added Menuitem.
    19           CommandBarControl oControl = oPopup.Controls.Add(MsoControlType.msoControlButton,
    20                                                            System.Reflection.Missing.Value,
    21                                                            System.Reflection.Missing.Value, 1true);
    22           // Set the caption of the submenuitem
    23           oControl.Caption = "Execute";
    24 
    25           // Now that we have added the menu items,
    26           // we will associate the click events for these items.
    27           // I will associate a click event only for the SubMenuitem at present.
    28           oSubMenuItemHandler = (CommandBarEvents)_applicationObject.Events.get_CommandBarEvents(oControl);
    29           oSubMenuItemHandler.Click += new _dispCommandBarControlEvents_ClickEventHandler(oSubMenuItemHandler_Click);
    30 }
    31 
    32 /// <summary>
    33 /// Invoked on click of sub menu item.
    34 /// </summary>
    35 protected void oSubMenuItemHandler_Click(object CommandaBarControl, ref bool handled, ref bool cancelDefault)
    36 {
    37           XSDToEntityFrm frm = new XSDToEntityFrm();
    38           frm.ShowDialog();
    39 }
    XSDToEntityFrm.cs
    System.Diagnostics.Process p = new System.Diagnostics.Process();
    {
          p.StartInfo.FileName = "cmd.exe";
          p.StartInfo.UseShellExecute = false;
          p.StartInfo.RedirectStandardInput = true;
          p.StartInfo.RedirectStandardOutput = true;
          p.StartInfo.RedirectStandardError = true;
          p.StartInfo.CreateNoWindow = true;
          p.Start();
          p.StandardInput.WriteLine( String.Concat( @"%comspec% /k """"" , txtVsPath.Text , @""""" x86" ) );
          p.StandardInput.WriteLine( String.Concat( @"xsd /c /language:CS " , selectFile , @" /out:" , txtOutPath.Text ) );
          p.StandardInput.WriteLine( "Exit" );
          p.Close();
    }

    完整程序 XSDToEntity

    XML To XSD : xsd test.xml /outputdir:D:\

    XSD TO DataSet : xsd /dataset /language:CS Test.xsd (不过,不是每个xsd都是可以转换的)

    DLL To XSD : xsd Test.dll  (不过,不是每个DLL都是可以转换的)

  • 相关阅读:
    几个不同的关键XPath概念
    go get 下载的包放在哪里呢?
    之前写的关于chromedp的文章被别人转到CSDN,很受鼓励,再来一篇golang爬虫实例
    微信小程序填坑之旅(2)-wx.showLoading的时候,仍能点击穿透,造成重复点击button的问题
    微信小程序填坑之旅(1)-app.js中用云开发获取openid,在其他页上用app.globaldata.openid获取为空
    JS 定时器-setInterval、clearInterval、setTimeout
    微信小程序开发入门教程(四)---自己动手做个小程序
    MT【247】恒成立画图像
    MT【246】方程根$acksim$图像交点
    MT【245】小概率事件
  • 原文地址:https://www.cnblogs.com/RuiLei/p/1379162.html
Copyright © 2011-2022 走看看