当前位置: 首页 > news >正文

房产网站制作wordpress countdown timer

房产网站制作,wordpress countdown timer,o2o平台都有哪些,网络推广方案文案准备技术#xff1a; 1.C#基础知识 2.了解WCF基础知识 在正常的c#开发中我们是允许用子类去替换基类的#xff0c;这也是所谓的替换原则。但是我们在WCF中确不能用数据契约的子类来替换父类的#xff0c;因为这中间存在一个序列化的问题。举个例子#xff1a; 我们有数据契…准备技术      1.C#基础知识      2.了解WCF基础知识          在正常的c#开发中我们是允许用子类去替换基类的这也是所谓的替换原则。但是我们在WCF中确不能用数据契约的子类来替换父类的因为这中间存在一个序列化的问题。举个例子      我们有数据契约           [DataContract]           class Employee{...}      服务契约中           [ServiceContract]           interface IEmployeeManager           {                [OperationContract]                void AddEmployee(Employee employee);           }      然后我们在客户端的代理中就算有类Intern继承于           [DataContract]           class Intern:Employee{...}      然后再客户端调用时           proxy.AddEmployee(new Intern())是会出错的。因为在服务器端无法识别Intern对象因为他无法去反序列化Intern成Employee对象(WCF序列化)。                  WCF提供给我们了一个解决的办法就是使用KnownTypeAttribute特性在基类上标识对应的子类就可以了。KnownTypeAttribute特性可以使用在Struct跟Class上。示例           [DataContract]           [KnownType(typeof(Customer))]           class Employee{...}                      [DataContract]           class Intern:Employee{...} 这样我们就在所有的契约跟操作上能跨越所有的服务和终结点允许服务接受子类。但是这样会遇到一个问题我们不能去特定的指定某一个服务操作所以KnownType的缺陷就是范围过于广泛。WCF提供了另外一个Attribute--ServiceKnownType.   ServiceKnownType 特性      KnownType只能应用在数据契约的基类上而ServiceKnownType可以在Interface、Method、Class上标识。看一个示例Employee.cs   Codeusing System;using System.Collections.Generic;using System.Linq;using System.Text;using System.ServiceModel;using System.Runtime.Serialization;namespace HenllyeeDataContract {     [DataContract]     public class Employee     {         #region Fields         private string _name;         private int _age;         #endregion         #region Properties         /// summary         /// The employees name         /// /summary        [DataMember(Order0)]         public string Name         {             get              {                 return this._name;             }             set             {                 this._name  value;             }         }         /// summary         /// The employees age         /// /summary        [DataMember(Order1)]         public int Age         {             get             {                 return this._age;             }             set             {                 this._age  value;             }         }         #endregion     }     [DataContract]     public class Intern : Employee     {         private int _internship;         /// summary         /// The interns working days         /// /summary        [DataMember]         public int Internship         {             get             {                 return this._internship;             }             set             {                 this._internship  value;             }         }     } }   在数据契约中我们并没有去指定KnownType我们在服务契约的操作上去标识ServiceKnownType特性EmployeeManage.cs:     Codeusing System;using System.Collections.Generic;using System.Linq;using System.Text;using System.ServiceModel;using System.Runtime.Serialization;namespace HenllyeeServiceContract {     [ServiceContract]     public interface IEmployeeManage     {         [OperationContract]         [ServiceKnownType(typeof(HenllyeeDataContract.Intern))]         void AddEmployee(HenllyeeDataContract.Employee emlpoyee);         [OperationContract]         [ServiceKnownType(typeof(HenllyeeDataContract.Intern))]         HenllyeeDataContract.Employee GetEmployee();     }     [ServiceBehavior(InstanceContextModeInstanceContextMode.Single)]     public class EmployeeManage : IEmployeeManage     {         private HenllyeeDataContract.Employee _employee;         /// summary         /// Set employee         /// /summary         /// param nameemlpoyeethe employees object/param        public void AddEmployee(HenllyeeDataContract.Employee emlpoyee)         {             this._employee  emlpoyee;         }         /// summary         /// Get a employee         /// /summary         /// returns/returns        public HenllyeeDataContract.Employee GetEmployee()         {             return this._employee;         }     } }   在客户端我们调用     Codeusing System;using System.Collections.Generic;using System.Linq;using System.Text;namespace Client {     class Program     {         static void Main(string[] args)         {             EmployeeService.EmployeeManageClient proxy  new Client.EmployeeService.EmployeeManageClient();             EmployeeService.Intern intern  new Client.EmployeeService.Intern();             intern.Age  22;             intern.Name  Henllyee Cui;             intern.Internship  120;             proxy.AddEmployee(intern);             EmployeeService.Employee internOut  proxy.GetEmployee();             Console.Write(The Employee Name:{0}\nAge:{1}\n,                 internOut.Name,                 internOut.Age                 );             Console.Read();         }     } } 运行后       ServiceKnownType特性也可以表示在数据契约的类上那么就会应用到整个数据契约中操作上如           [ServiceContract]           [ServiceDataContract(typeof(HenllyeeDataContract.Intern))]           public interface IEmployeeManage{...}      那么IEmployeeManage服务契约跟其所有的操作都可以接受Intern这个子类. 已知类型与接口      数据契约DataContract只能标识在class 或者struct上但是数据契约的基类可以是接口,但是我们在服务契约的时候要去用ServiceKnownType特性去指定确切的数据类型。如:      interface IEmployee{...}      [DataContract]      class Intern:IEmployee{...} 服务契约中      [ServiceContract]      [ServiceKnownType(typeof(Intern))]      interface IEmployeeManage      {           [OperationContract]           void AdddEmployee(IEmployee employee);      } 要注意的一点就是我们不能把KnownType特性应用到基接口上因为客服端导出的元数据是不能包含接口本身的。 [代码下载] 作者Henllyee Cui出处 http://henllyee.cnblogs.com/ 本文版权归作者和博客园共有欢迎转载但未经作者同意必须保留此段声明。 转载于:https://www.cnblogs.com/Henllyee/archive/2008/08/26/1276995.html
http://www.sadfv.cn/news/190490/

相关文章:

  • 合肥市做效果图的网站wordpress电商平台
  • 水墨风格网站欣赏平面设计素材网站哪个好
  • 王悦做网站wordpress 少数派
  • 禹城做网站的学校网站建设情况报告
  • 建设机械网站精英网站页尾的作用
  • 国外网站模板郑州app下载
  • 做买鞋网站的论文wordpress添加磁力下载
  • 浙江高端建设网站高端html5网站建设
  • 做标签这个网站刷单安全吗2019建设摩托官方网站
  • 网站开发项目任务wordpress 打开速度慢
  • 自己创做网站深圳做网站de公司
  • 免费免费建网站济宁个人网站建设价格便宜
  • 网站建设数据库搭建咸阳网站开发哪家好
  • 网站备案背景幕布设计公司网站需要什么条件
  • 安卓 网站制作wordpress免费导航主题
  • 惠州网站建设学校企业官网邮箱怎样申请
  • 关于网站的建设大连网站建设制作公司
  • 上海制作网站的公司做app好 还是讯网站好
  • 如何新建站点wordpress无法目录下
  • 网站制作开发 杭州公司官网的意义
  • 简述网站建设的标准宁波网站开发制作
  • 中卫网站制作公司云南省建设厅网站处长
  • 博士后是否可以做网站负责人成都分销商城网站建设
  • 上海网站建设域名做游戏制作 网站
  • 广告建设网站电商网站建设培训
  • 安徽伟诚建设工程有限公司网站企业网站建设应该计入哪个科目
  • 开发软件怎么开发vps wordpress mysql优化
  • 自己做的微课上传到哪个网站有哪些网站可以免费发布广告
  • 现在网站建设尺寸一般多少河南城乡与住房建设厅网站
  • 网站建设的报价做网站开发的集团