What code you will get when you create a wcf library
生活随笔
收集整理的這篇文章主要介紹了
What code you will get when you create a wcf library
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
?
創建wcf服務庫的時候,系統自動生成的代碼
// 注意: 使用“重構”菜單上的“重命名”命令,可以同時更改代碼和配置文件中的接口名“IService1”。 [ServiceContract]public interface IService1{[OperationContract]string GetData(int value);[OperationContract]CompositeType GetDataUsingDataContract(CompositeType composite);// TODO: 在此添加您的服務操作 }// 使用下面示例中說明的數據約定將復合類型添加到服務操作。// 可以將 XSD 文件添加到項目中。在生成項目后,可以通過命名空間“WcfServiceLib.ContractType”直接使用其中定義的數據類型。 [DataContract]public class CompositeType{bool boolValue = true;string stringValue = "Hello ";[DataMember]public bool BoolValue{get { return boolValue; }set { boolValue = value; }}[DataMember]public string StringValue{get { return stringValue; }set { stringValue = value; }}}服務實現
// 注意: 使用“重構”菜單上的“重命名”命令,可以同時更改代碼和配置文件中的類名“Service1”。public class Service1 : IService1{public string GetData(int value){return string.Format("You entered: {0}", value);}public CompositeType GetDataUsingDataContract(CompositeType composite){if (composite == null){throw new ArgumentNullException("composite");}if (composite.BoolValue){composite.StringValue += "Suffix";}return composite;}}?
轉載于:https://www.cnblogs.com/chucklu/p/4635071.html
總結
以上是生活随笔為你收集整理的What code you will get when you create a wcf library的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: VC++ EasyPR车牌识别
- 下一篇: 宝塔面板 python管理器2.0安装M