2013年3月28日

抽象工厂模式-典型例子

摘要: http://blog.csdn.net/zhlyyea/article/details/2114654 阅读全文

posted @ 2013-03-28 16:14 HOT SUMMER 阅读(171) 评论(0) 推荐(0)

典型工厂化实现

摘要: 工厂接口定义 /// <summary> /// 工厂接口定义 /// </summary> /// <remarks> /// TTarget : abstract product type /// TSource: concrete product type /// </remarks> public interface IFactory { #region config and register type mapping /// <summary> /// 如果需要同时加载配置文... 阅读全文

posted @ 2013-03-28 14:25 HOT SUMMER 阅读(288) 评论(0) 推荐(0)

利用配置文件解耦工厂类型

摘要: 定义一个接口 public interface IFactory { IProduct Create(); // 返回默认的 concrete product IProduct Create(string name); // 按照配置的逻辑名称返回指定的concrete product }获取配置类 public class ProductRegistry { const string SectionName = "concreteProducts"; static NameValueC... 阅读全文

posted @ 2013-03-28 13:10 HOT SUMMER 阅读(208) 评论(0) 推荐(0)

简单工厂模式扩展------工厂方法模式

摘要: 工厂方法模式就是把该类的实例化过程延迟到子类,将new工作交给工厂完成,同时对工厂自身进行抽象,然后客户端程序基于工厂的抽象行为构造所需的实例类型 /// <summary> /// 抽象产品类型 /// </summary> public interface IProduct { string Name { get;} // 约定的抽象产品所必须具有的特征 } /// <summary> /// 具体产品类型 /// </summary> public class ProductA : IProduct { ... 阅读全文

posted @ 2013-03-28 11:55 HOT SUMMER 阅读(304) 评论(0) 推荐(0)

最简单的工厂模式

摘要: 你想如果有多个类似的类,我们就需要实例化出来多个类。这样代码管理起来就太复杂了。 这个时候你就可以采用工厂方法来封装这个问题。 public interface IProduct { } public class ConcreteProductA : IProduct { } public class ConcreteProductB : IProduct { } public class Factory { public IProduct Create() { // 工厂决定到底实例化哪个子类。 ... 阅读全文

posted @ 2013-03-28 10:58 HOT SUMMER 阅读(217) 评论(0) 推荐(0)

导航