在系統開發過程中
我們同樣通過Dome來說話
Data Contract
using System;
using System
using System
using System
using System
namespace Artech
{
[DataContract(Namespace=
public class Order
{
[DataMember(Order =
public Guid OrderID
{get;set;}
[DataMember(Order =
public DateTime OrderDate
{ get; set; }
[DataMember(Order =
public Guid SupplierID
{ get; set; }
}
}
Service Contract 和Service Implementation: Process方法簡單地將Order對象返回到客戶端
using System;
using System
using System
using System
using System
namespace Artech
{
[ServiceContract]
public interface IOrderManager
{
[OperationContract]
Order Process(Order order);
}
}
namespace Artech
{
public class OrderManagerService:IOrderManager
{
IOrderManager Members#region IOrderManager Members
public Order Process(Order order)
{
return order;
}
#endregion
}
}
Data Contract
[DataContract(Name=
public class CustomOrder
{
[DataMember(Order =
public Guid OrderNo
{ get; set; }
[DataMember(Order =
public Guid SupplierNo
{ get; set; }
[DataMember(Order =
public DateTime OrderDate
{ get; set; }
}
}
Program
namespace Artech
{
class Program
{
static void Main(string[] args)
{
ChannelFactory
IOrderManager orderManager = channelFactory
try
{
CustomOrder order = new CustomOrder { OrderNo = Guid
SupplierNo = Guid
ShippingAddress=
Jiangsu Province
Console
order = orderManager
Console
order
}
finally
{
(orderManager as IDisposable)
}
Console
}
}
}
通過上面的分析
現在我們在Client端為Custom添加一個新的成員
namespace Artech
{
[DataContract(Name=
public class CustomOrder
{
[DataMember(Order =
public Guid OrderNo
{ get; set; }
[DataMember(Order =
public Guid SupplierNo
{ get; set; }
[DataMember(Order =
public DateTime OrderDate
{ get; set; }
[DataMember(Order =
public string ShippingAddress
{ get; set; }
public override string ToString()
{
return string
{
this
}
}
}
我們來看看Client端程序運行的輸出結果