分享.NET代碼產生器(ZAP)

來源:互聯網
上載者:User

        在網上發現了一個.NET代碼產生器,可以自動產生網站,包括前台頁面,還可以按關係產生相應的代碼,以及資料庫等。這個軟體是ZAP,而且更重要的是他開放原始碼,不知道大家用過沒有。下面我簡單介紹一下。

安裝方法:
1、軟體及原始碼:http://www.superexpert.com/Code/ZAP/ZAPInstall_032307.zip。
2、下載後將其解壓到你的硬碟上。
3、大開VS2005 在工具菜單中選擇外部工具。在外部工具對話方塊中點擊添加。
4、將加入的新工具標題命名為“ZAP”,然後選擇命令的可執行檔,這裡在你的硬碟上選擇 ZAPTool\ZAP.exe,並將初時目錄修改為“$(ProjectDir)”,選中輸出視窗對話方塊,確定即可。如所示:

使用方法:
1、 開啟VS2005 建立網站,選擇空項目。
2、 選擇工具中的ZAP,執行產生網站。
網站產生後.NET IDE 不會自動重新整理項目目錄,要查看ZAP產生的結果,請在“解決資源管理員”中點擊重新整理按鈕。結果如:

ZAP的這些類都是按照zap.config中的配置產生的,我們可以修改他,讓他來產生我們所需要的類和控制項。預設的zap.config代碼如下:

<project
  xmlns="http://superexpert.com/zap" 
  name="Project1">

<classes>
  <class id="Class1">
    <properties>
      <property 
        name="id" 
        type="Int32" 
        isPrimaryKey="true" 
        isIdentity="true" />
      <property name="title"/>
    </properties>
  </class>
</classes>

</project>


下面是修改後的zap.config代碼:

<project
  xmlns="http://superexpert.com/zap" 
  name="Project1">

<classes>
  <class id="MovieCategory">
    <properties>
      <property 
        name="id" 
        type="Int32" 
        isPrimaryKey="true" 
        isIdentity="true" />
      <property name="name" label="Name"/>
    </properties>
  </class>

  <class id="Movie">
    <properties>
      <property 
        name="id" 
        type="Int32" 
        isPrimaryKey="true" 
        isIdentity="true" />
      <property 
        name="title" 
        label="Title"/>
      <property 
        name="director" 
        label="Director"/>
      <property
        name="categoryId"
        widget="DropDownList" 
        foreignClassId="MovieCategory"
        foreignValuePropertyName="id"
        foreignTextPropertyName="name" />
    </properties>
  </class>

</classes>

</project>


修改完畢後重新整理解決資源管理員,看ZAP為我們產生的程式碼、頁面和控制項,相信會讓你大吃一驚的,如:

開啟ZAP下的MovieCategoryList.aspx檔案,按Ctrl + F5運行項目,向系統中加入電影的分類,然後運行MovieList.aspx,結果如:

關於ZAP 的配置以及更多資訊請參見http://www.superexpert.com/Blog/Archive/17.aspx

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.