using System; // Strategy Pattern by Judith Bishop Oct 2007 // Shows two strategies an5
i++
转载 2012-05-17 21:04:00
104阅读
2评论
using System; class CommandPattern { // Command Pattern Judith Bishop June 2007 // // Uses a single delegate for the single type of commands that the client invokes. delegate void Invoker (); static I...
转载 2010-08-26 23:10:00
101阅读
2评论
using System; class SingletonPattern { // Singleton Pattern Judith Bishop Nov 2007 // The public property protects the private constructor public class Singleton { // Private constructor Singleton () { } // Nested class for lazy instantiation class SingletonCreator { static SingletonCreator () {...
转载 2012-05-14 21:26:00
59阅读
2评论
using System; class SingletonPattern { // Singleton Pattern Judith Bishop Dec 2006 // The public property protects the private constructor public sealed class Singleton { // Private Constructor Singleton() { } // Private object instantiated with private constructor static readonly Singleton inst...
转载 2012-05-14 21:24:00
48阅读
2评论
using System; //Decorator Pattern Judith Bishop Dec 2006 // Shows two decorators and the output of various // combinations of the decorators on the basic component interface IComponent { string Operation(); } class Component : IComponent { public string Operation () { return "I am walking &quot
转载 2012-05-11 14:15:00
94阅读
2评论
using System; using System.Collections.Generic; using System.Runtime.Serialization; using PrototypePattern; // Prototype Pattern Judith Bishop Dec 2006 // The AbstractProtoype is represented by the ICloneable interface // Serializable is used for the deep copy option [Serializable()] // Helper cla..
转载 2012-05-14 21:23:00
191阅读
2评论
using System; // Adapter Pattern - Simple Judith Bishop Aug 2006 // Simplest adapter using interfaces and inheritance // Existing way requests are implemented class Adaptee { // Provide full precision public double SpecificRequest (double a, double b) { return a/b; } } // Required standard for ...
转载 2012-05-14 20:33:00
41阅读
2评论
using System; class BridgePattern { // Bridge Pattern Judith Bishop Dec 2006, Aug 2007 // Shows an abstraction and two implementations proceeding independently class Abstraction { Bridge bridge; public Abstraction (Bridge implementation) { bridge = implementation; } public string Operation () { re..
转载 2012-05-10 17:29:00
48阅读
2评论
using System;namespace AbstractFactoryPattern { // Abstract Factory D-J Miller and Judith Bishop Sept 2007 // Uses generics to simplify the creation of factories interface IFactory<Brand> where Brand : IBrand { IBag CreateBag(); IShoes CreateShoes(); } // Conctete Factories (both in the same o
转载 2012-05-14 21:33:00
86阅读
2评论
using System; // Proxy Pattern Judith Bishop Dec 2006 // Shows virtual and protection proxies class SubjectAccessor { public interface ISubject { string Request (); } private class Subject { public string Request() { return "Subject Request " + "Choose left door\n"; } } public cl
转载 2012-05-11 14:23:00
90阅读
2评论
using System; using System.Collections.Generic; // Proxy Pattern Example Judith Bishop Aug 2007 // Sets up a SpaceBook page with registration and authentication class SpaceBookSystem { // The Subject private class SpaceBook { static SortedList <string,SpaceBook> community = new SortedList <
转载 2012-05-11 14:23:00
105阅读
2评论
using System; using System.Collections.Generic; using System.IO; using CompositePattern; // Composite Pattern Judith Bishop August 2007 // The pattern is generic, and an example is given for a real world client // The Client class CompositePatternExample { static void Main () { IComponent <string
转载 2012-05-11 16:23:00
79阅读
2评论
using System; using System.Collections; class FactoryPattern { // Factory Method Pattern Judith Bishop 2006 // Example of exporting from different suppliers interface IProduct { string ShipFrom(); } class ProductA : IProduct { public String ShipFrom () { return " from South Africa"; } } cl
转载 2012-05-14 21:11:00
64阅读
2评论
using System; // Adapter Pattern - Pluggable Judith Bishop Aug 2006 // Adapter can accept any number of pluggable adaptees and targets // and route the requests via a delegate, in some cases using the // anonymous delegate construct // Existing way requests are implemented class Adaptee { public...
转载 2012-05-14 20:32:00
85阅读
2评论
using System; using EngineeringService; // Two-way Adapter Pattern Pierre-Henri Kuate and Judith Bishop Aug 2007 // Embedded system for a SeaBird flying plane namespace EngineeringService { //ITarget interface public interface IAircraft { bool Airborne {get;} void TakeOff(); int Height {get;} }...
转载 2012-05-14 20:34:00
74阅读
2评论
using System; // Interpreter Pattern - Example Judith Bishop October 2007 // Sets up an object structure and interprets it with given data static class ElementExtensions { public static string gap; public static void Print(this Element element) { Console.WriteLine(gap+element + " " + eleme
转载 2012-05-08 16:45:00
83阅读
2评论
using System; using System.Reflection; using ObjectStructure; // Visitor Pattern - Example Judith Bishop October 2007 // Sets up an object structure and visits it // in two ways - for counting using reflection namespace ObjectStructure { class Element { public Element Next {get; set;} public Elem...
转载 2012-05-11 14:13:00
50阅读
2评论
using System;using System.Collections.Generic; // Bridge Pattern Example Judith Bishop Dec 2006, Aug 2007 // Extending SpaceBook with a second implementation via a Portal // Abstraction class Portal { Bridge bridge; public Portal (Bridge aSpaceBook) { bridge = aSpaceBook; } public void Add(string...
转载 2012-05-10 17:28:00
72阅读
2评论
using System; using System.Collections; using System.Threading; class ObserverPattern { //Observer Pattern Judith Bishop Jan 2007 // The Subject runs in a thread and changes its state // independently. At each change, it notifies its Observers. class Subject { public delegate void Callback (stri...
转载 2012-05-21 18:52:00
74阅读
2评论
using System; // Facade Pattern Judith Bishop Dec 2006 // Sets up a library of three systems, accessed through a // Facade of two operations // Compile with csc /t:library /out:FacadeLib.dll Facade2.cs namespace FacadeLib { internal class SubsystemA { internal string A1() { return "Subsystem A,
转载 2012-05-14 20:39:00
42阅读
2评论
  • 1
  • 2