李维:Windows 原生開發工具的瑰寶 – Delphi 6(4…
2008-04-09 04:29:52来源:互联网 阅读 ()
件,然後自動產生以Object Pascal封裝的程式碼,讓程式師直接可以呼叫自動產生的
程式碼中的方法來存取XML封裝的資料,不再需要使用XML Document元件來辛苦的
自己分析XML之中的資料,而且執行效率也比較好。
例如下面的圖形就是Delphi 6中XML Data Binding精靈的畫面。在這個精靈中我匯入
了一個封裝股市資訊的XML檔案,那麼這個這個精靈便會自動產生如下的Object
Pascal程式碼:



Delphi 6 的XML Data Binding精靈
在下面的程式碼中,我只需要存取TXMLStockType類別之中的功能,例如Get_Price,
就可以輕易的取得XML文件之中股票的價格,不再需要使用XML Document元件來分
析,這樣是不是快多了,而且不容易出錯呢?在支援XML方面,Borland的確為程式師
設想了許多的東西,也提昇了Delphi程式師許多的生產力,而XML Data Binding精靈
特別適合使用在程式師需要經常處理大量格式固定的XML文件。
IXMLStockListType = interface;
IXMLStockType = interface;
{ IXMLStockListType }
IXMLStockListType = interface(IXMLNodeCollection)
[''''{F56A36C4-4014-11D5-8B76-E593B0087905}'''']
{ Property Accessors }
function Get_Stock(Index: Integer): IXMLStockType;
{ Methods & Properties }
function Add: IXMLStockType;
function Insert(const Index: Integer): IXMLStockType;
property Stock[Index: Integer]: IXMLStockType read Get_Stock; default;
end;
{ IXMLStockType }
IXMLStockType = interface(IXMLNode)
[''''{F56A36C5-4014-11D5-8B76-E593B0087905}'''']
{ Property Accessors }
function Get_Exchange: WideString;
function Get_Name: WideString;
function Get_Price: WideString;
function Get_Symbol: WideString;
function Get_Volume: WideString;
procedure Set_Exchange(Value: WideString);
procedure Set_Name(Value: WideString);
procedure Set_Price(Value: WideString);
procedure Set_Symbol(Value: WideString);
procedure Set_Volume(Value: WideString);
{ Methods & Properties }
property Exchange: WideString read Get_Exchange write Set_Exchange;
property Name: WideString read Get_Name write Set_Name;
property Price: WideString read Get_Price write Set_Price;
property Symbol: WideString read Get_Symbol write Set_Symbol;
property Volume: WideString read Get_Volume write Set_Volume;
end;
{ Forward Decls }
TXMLStockListType = class;
TXMLStockType = class;
{ TXMLStockListType }
TXMLStockListType = class(TXMLNodeCollection, IXMLStockListType)
protected
{ IXMLStockListType }
function Get_Stock(Index: Integer): IXMLStockType;
function Add: IXMLStockType;
function Insert(const Index: Integer): IXMLStockType;
public
procedure AfterConstruction; override;
end;
{ TXMLStockType }
TXMLStockType = class(TXMLNode, IXMLStockType)
protected
{ IXMLStockType }
function Get_Exchange: WideString;
function Get_Name: WideString;
function Get_Price: WideString;
function Get_Symbol: WideString;
function Get_Volume: WideString;
procedure Set_Exchange(Value: WideString);
procedure Set_Name(Value: WideString);
procedure Set_Price(Value: WideString);
procedure Set_Symbol(Value: WideString);
procedure Set_Volume(Value: WideString);
end;
開發Web Service的精靈和元件
Web Service也是現在最熱門的Web技術了,不管是IBM或是Microsoft都在發展Web
Service的解決方案。Delphi 6在這方面也不落後,Delphi 6提供了SOAP和Web Service
精靈,讓程式師能夠快速的開發SOAP應用系統,也可以匯入WSDL自動產生骨架程
式碼。由於SOAP是未來Web和分散式應用系統的主流技術,而Web Service更是未來
Web應用系統的主要軟體架構,因此對於程式師來說,掌握這些技術便成了非常重要
的課題。
Delphi 6是Borland支援SOAP的第一個產品,由於SOAP是標準的協定,因此藉由
Delphi 6開發的SOAP應用系統可以和COM ,EJB或是Microsoft的.NET溝通,Delphi的
程式師現在就可以使用它開發未來的應用系統。下圖便是Delphi 6提供的SOAP精靈,
在Delphi 6中也提供了6個VCL元件讓程式師開發SOAP和Web Service的應用系統。

Delphi 6 允許程式師快速建立SOAP應用程式和Web Service

由Delphi 6 自動產生的SOAP模組
由於SOAP是Delphi 6重要的功能,又是現在最流行的技術,因此希望在未來的
RUN!PC文章中能夠有機會詳細的為各位介紹如何使用Delphi 6的SOAP和Web Service
技術開發應用系統 並且和其他的系統整合。
重新再造的執行時期函式館
對於Delphi 6和Kylix來說,Borland進行的隱形工程就是它們的執行時期函式館(Run
Time Library-RTL)了。Delphi 6的RTL不但為了跨平台而重新的整理過,而且加入了許
多新的RTL公用函式,以便讓程式師呼叫。這些新增的函式數目超過了數10個,例如
,光是有關DateTime的函式就有數10個。此外Borland為了讓Delphi 6中的Variant型態
和函式也能夠使用在Linux平台,因此特別新增了Variants.PAS這個程式單元,讓兩個
平台同時擁有Variant型態的變數和函式可以使用。
标签:
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有
IDC资讯: 主机资讯 注册资讯 托管资讯 vps资讯 网站建设
网站运营: 建站经验 策划盈利 搜索优化 网站推广 免费资源
网络编程: Asp.Net编程 Asp编程 Php编程 Xml编程 Access Mssql Mysql 其它
服务器技术: Web服务器 Ftp服务器 Mail服务器 Dns服务器 安全防护
软件技巧: 其它软件 Word Excel Powerpoint Ghost Vista QQ空间 QQ FlashGet 迅雷
网页制作: FrontPages Dreamweaver Javascript css photoshop fireworks Flash
