程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> .NET網頁編程 >> 關於.NET >> XSD To Entity -- Vs2008 Add Ins

XSD To Entity -- Vs2008 Add Ins

編輯:關於.NET

最近閒得無事,不過也是為了以後設計的一個環節,做了一個Add-Ins

主要是XSD To Entity的操作。

Step 1:先配置一下

把相關的AddIn、DLL Copy To 當前用戶\文檔\Visual Studio 200X\Addins

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

Step 3:現在隨便打開一個project,然後在Code Windows中右擊,就可以看到XSD To Entity

界面

選擇一個XSD File

轉換完成

轉換文件

代碼方面:

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, 1, true);
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, 1, true);
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();
}

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都是可以轉換的)

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved