上一页 1 ··· 37 38 39 40 41 42 43 44 45 ··· 55 下一页

2013年3月29日

Builder模式-加特性

摘要: 其实这种设计思想也来源于生活,比如生活中,我们在淘宝上买哥电脑桌,我们要组装它,这类产品都有一个共同点就是会把零件上标好标志1.定义在指导属性创建特性类 /// <summary> /// 指导每个具体类型BuildPart过程目标方法和执行情况的属性 /// </summary> [AttributeUsage(AttributeTargets.Method, AllowMultiple = false)] public sealed class BuildStepAttribute : Attribute { int sequence; ... 阅读全文

posted @ 2013-03-29 13:51 HOT SUMMER 阅读(295) 评论(0) 推荐(0)

Builder模式--经典模式

摘要: public class Vehicle { public IEnumerable<string> Wheels { get; set; } public IEnumerable<string> Lights { get; set; } } /// <summary> /// abstract builder /// </summary> public abstract class VehicleBuilderBase { public Vehicle Vehicle { get; protected se... 阅读全文

posted @ 2013-03-29 11:02 HOT SUMMER 阅读(171) 评论(0) 推荐(0)

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)

2013年3月27日

LINQ相关知识还是要补充下的

摘要: LINQ相关知识还是要补充下的,待续 阅读全文

posted @ 2013-03-27 15:52 HOT SUMMER 阅读(118) 评论(0) 推荐(0)

前两章的总结

摘要: 关于前两章的一些总结回顾,其实设计模式的精髓在于分离,抽象,简洁,方便,在熟悉一些c#流行语法,加深对事件和代理的理解,以及应用,通过这些手段来分离包装对象,从而达到更好的实现分离抽象,,我想这就是设计模式的精髓所在 阅读全文

posted @ 2013-03-27 14:29 HOT SUMMER 阅读(123) 评论(0) 推荐(0)

连贯接口 fluent interface

摘要: public class Currency { /// <summary> /// 货币代码 /// </summary> public string Code { get; set; } /// <summary> /// 货币名称 /// </summary> public string Name { get; set; } } public interface IDataFacade { /// <summary> /// 根... 阅读全文

posted @ 2013-03-27 14:11 HOT SUMMER 阅读(308) 评论(0) 推荐(0)

上一页 1 ··· 37 38 39 40 41 42 43 44 45 ··· 55 下一页

导航