[索引页]
[源码下载]


乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)


作者:webabcd


介绍
将抽象部分与它的实现部分分离,使它们都可以独立地变化。


示例
有一个Message实体类,对它的操作有Insert()和Get()方法,现在使这些操作的抽象部分和实现部分分离。
乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)


MessageModel
乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)using System;
乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)
using System.Collections.Generic;
乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)
using System.Text;
乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)
乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)
namespace Pattern.Bridge

Message
乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)using System;
乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)
using System.Collections.Generic;
乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)
using System.Text;
乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)
乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)
namespace Pattern.Bridge

MyMessage
乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)using System;
乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)
using System.Collections.Generic;
乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)
using System.Text;
乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)
乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)
namespace Pattern.Bridge

AbstractMessage
乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)using System;
乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)
using System.Collections.Generic;
乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)
using System.Text;
乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)
乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)
namespace Pattern.Bridge

SqlMessage
乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)using System;
乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)
using System.Collections.Generic;
乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)
using System.Text;
乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)
乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)
namespace Pattern.Bridge

XmlMessage
乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)using System;
乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)
using System.Collections.Generic;
乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)
using System.Text;
乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)
乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)
namespace Pattern.Bridge


Test
乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)using System;
乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)
using System.Data;
乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)
using System.Configuration;
乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)
using System.Collections;
乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)
using System.Web;
乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)
using System.Web.Security;
乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)
using System.Web.UI;
乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)
using System.Web.UI.WebControls;
乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)
using System.Web.UI.WebControls.WebParts;
乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)
using System.Web.UI.HtmlControls;
乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)
乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)
using Pattern.Bridge;
乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)
乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)
public partial class Bridge : System.Web.UI.Page

运行结果
True
SQL方式获取Message(RefinedAbstraction) 2007-5-13 19:11:19
True
XML方式获取Message(RefinedAbstraction) 2007-5-13 19:11:19


参考
http://www.dofactory.com/Patterns/PatternBridge.aspx


OK
[源码下载]

相关文章: