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

时间:2023-03-08 22:39:45

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

[索引页][源码下载]

乐在其中设计模式(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

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

乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)    /**//// <summary>

乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)    /// Message实体类

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

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

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

乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)        /**//// <summary>

乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)        /// 构造函数

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

乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)        /// <param name="msg">Message内容</param>

乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)        /// <param name="pt">Message发布时间</param>

乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)        public MessageModel(string msg, DateTime pt)

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

乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)            this._message = msg;

乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)            this._publishTime = pt;

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

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

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

乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)        /**//// <summary>

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

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

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

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

乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)            get 乐在其中设计模式(C#) - 桥接模式(Bridge Pattern){ return _message; }

乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)            set 乐在其中设计模式(C#) - 桥接模式(Bridge Pattern){ _message = value; }

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

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

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

乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)        /**//// <summary>

乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)        /// Message发布时间

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

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

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

乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)            get 乐在其中设计模式(C#) - 桥接模式(Bridge Pattern){ return _publishTime; }

乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)            set 乐在其中设计模式(C#) - 桥接模式(Bridge Pattern){ _publishTime = value; }

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

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

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

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

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

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

乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)    /**//// <summary>

乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)    /// 操作Message(Abstraction)

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

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

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

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

乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)        /**//// <summary>

乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)        /// 操作Message(Implementor)

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

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

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

乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)            get 乐在其中设计模式(C#) - 桥接模式(Bridge Pattern){ return _abstractMessage; }

乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)            set 乐在其中设计模式(C#) - 桥接模式(Bridge Pattern){ _abstractMessage = value; }

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

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

乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)        /**//// <summary>

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

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

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

乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)        public virtual List<MessageModel> Get()

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

乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)            return _abstractMessage.Get();

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

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

乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)        /**//// <summary>

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

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

乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)        /// <param name="mm">Message实体对象</param>

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

乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)        public virtual bool Insert(MessageModel mm)

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

乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)            return _abstractMessage.Insert(mm);

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

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

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

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

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

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

乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)    /**//// <summary>

乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)    /// 操作Message(RefinedAbstraction)

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

乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)    public class MyMessage : Message

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

乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)        /**//// <summary>

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

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

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

乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)        public override List<MessageModel> Get()

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

乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)            List<MessageModel> l = base.Get();

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

乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)            foreach (MessageModel mm in l)

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

乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)                mm.Message += "(RefinedAbstraction)";

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

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

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

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

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

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

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

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

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

乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)    /**//// <summary>

乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)    /// 操作Message(Implementor)

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

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

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

乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)        /**//// <summary>

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

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

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

乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)        public abstract List<MessageModel> Get();

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

乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)        /**//// <summary>

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

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

乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)        /// <param name="mm">Message实体对象</param>

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

乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)        public abstract bool Insert(MessageModel mm);

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

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

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

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

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

乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)    /**//// <summary>

乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)    /// Sql方式操作Message(ConcreteImplementor)

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

乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)    public class SqlMessage : AbstractMessage

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

乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)        /**//// <summary>

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

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

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

乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)        public override List<MessageModel> Get()

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

乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)            List<MessageModel> l = new List<MessageModel>();

乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)            l.Add(new MessageModel("SQL方式获取Message", DateTime.Now));

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

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

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

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

乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)        /**//// <summary>

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

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

乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)        /// <param name="mm">Message实体对象</param>

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

乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)        public override bool Insert(MessageModel mm)

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

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

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

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

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

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

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

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

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

乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)    /**//// <summary>

乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)    /// Xml方式操作Message(ConcreteImplementor)

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

乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)    public class XmlMessage : AbstractMessage

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

乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)        /**//// <summary>

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

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

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

乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)        public override List<MessageModel> Get()

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

乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)            List<MessageModel> l = new List<MessageModel>();

乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)            l.Add(new MessageModel("XML方式获取Message", DateTime.Now));

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

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

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

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

乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)        /**//// <summary>

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

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

乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)        /// <param name="mm">Message实体对象</param>

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

乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)        public override bool Insert(MessageModel mm)

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

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

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

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

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

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

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

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

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

乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)    protected void Page_Load(object sender, EventArgs e)

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

乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)        MyMessage m = new MyMessage();

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

乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)        m.AbstractMessage = new SqlMessage();

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

乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)        Response.Write(m.Insert(new MessageModel("插入", DateTime.Now)));

乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)        Response.Write("<br />");

乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)        Response.Write(m.Get()[].PublishTime.ToString());

乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)        Response.Write("<br />");

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

乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)        m.AbstractMessage = new XmlMessage();

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

乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)        Response.Write(m.Insert(new MessageModel("插入", DateTime.Now)));

乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)        Response.Write("<br />");

乐在其中设计模式(C#) - 桥接模式(Bridge Pattern)        Response.Write(m.Get()[].PublishTime.ToString());

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

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

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

运行结果

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

[源码下载]