摘要:
适配器设计模式是把一个类的接口转化成客户端期望的接口,从而使原本接口不匹配的两个类能一起工作。实际中这种场景很容易碰到,比如A类型手机充电器需要10V电压充电,B类型手机需要15V电压充电。A类型手机的充电器价格非常昂贵,而B类型的充电器价格低廉。市场就有可能出现把B型充电器转换成A型手机匹配的适配器。适配器设计模式有两种:类适配器:使用继承实现接口转换。实例适配器:使用组合实现接口转换。类适配器类图:类适配器设计的角色:源:被适配的类。目标:客户期望的接口.由于适配器需要继承源。所以目标必须是接口。适配器:把源接口转换成目标接口。适配器需要继承源。代码:using System;using 阅读全文
posted @ 2011-02-10 16:56
b0b0
阅读(315)
评论(6)
推荐(2)
摘要:
WCF 异步调用说明: WCF客户端异步调用与服务端代码没有关系,只是和客户端的代码有关系。服务端服务接口:代码Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;usingSystem.ServiceModel;namespaceConsoleAsyService{///<su 阅读全文
posted @ 2011-02-10 10:52
b0b0
阅读(551)
评论(0)
推荐(1)
摘要:
WCF 承载服务 WinForm 承载 WCF 服务端 服务代码 服务接口: namespace WCFService { [ServiceContract] public interface IServiceWindow { [OperationContract(IsOneWay=false)] string GetCurrentTime(); } } 服务实现: using System; using System.Collections.Generic; using System.Linq; using System.Runtime.Serializa 阅读全文
posted @ 2011-02-10 10:49
b0b0
阅读(785)
评论(0)
推荐(1)

浙公网安备 33010602011771号