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都是可以转换的)

  • 相关阅读:
    Spark 1.1.0 安装测试 (分布式 Yarn-cluster模式)
    HBase Mac OSX 安装笔记
    hbase centOS生产环境配置笔记 (1 NameNode, 1 ResourceManager, 3 DataNode)
    ssh 配置自动登录
    CentOS 修改线程数限制等(limits.conf)
    Hadoop Mac OSX 安装笔记
    centos7安装及部署zabbix监控
    设置linux中Tab键的宽度(可永久设置)
    基于NFS共享存储实现KVM虚拟机动态迁移
    KVM虚拟化平台环境部署
  • 原文地址:https://www.cnblogs.com/RuiLei/p/1379162.html
Copyright © 2011-2022 走看看