摘要:
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 () {... 阅读全文
posted @ 2012-05-14 21:26
ChaunceyHao
阅读(122)
评论(0)
推荐(0)
摘要:
using System; // Singleton PatternJudith Bishop Nov 2007 // Generic version public class Singleton <T> where T : class, new(){ Singleton() { } class SingletonCreator { static SingletonCreator () {} // Private object instantiated with private constructor internal static readonly T instance = ne 阅读全文
posted @ 2012-05-14 21:26
ChaunceyHao
阅读(135)
评论(0)
推荐(0)
摘要:
using System; using System.Collections.Generic; using System.Runtime.Serialization; using System.Runtime.Serialization.Formatters.Binary; namespace PrototypePattern { // Prototype Pattern Judith Bishop Dec 2006 // Serialization is used for the deep copy option [Serializable()] public abstract cla... 阅读全文
posted @ 2012-05-14 21:24
ChaunceyHao
阅读(187)
评论(0)
推荐(0)
摘要:
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... 阅读全文
posted @ 2012-05-14 21:24
ChaunceyHao
阅读(131)
评论(0)
推荐(0)
摘要:
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.. 阅读全文
posted @ 2012-05-14 21:23
ChaunceyHao
阅读(263)
评论(0)
推荐(0)
摘要:
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 阅读全文
posted @ 2012-05-14 21:11
ChaunceyHao
阅读(119)
评论(0)
推荐(0)
摘要:
using System; using System.Collections.Generic; using System.IO; using PrototypePattern; namespace CompositePattern { // The Interface public interface IComponent <T> { void Add(IComponent <T> c); IComponent <T> Remove(T s); string Display(int depth); IComponent <T> Find(T s) 阅读全文
posted @ 2012-05-14 21:07
ChaunceyHao
阅读(183)
评论(0)
推荐(0)
摘要:
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, 阅读全文
posted @ 2012-05-14 20:39
ChaunceyHao
阅读(127)
评论(0)
推荐(0)
摘要:
using System; using FacadeLib; // Compile with csc /r:FacadeLib.dll Facade2Main.cs class FacadePattern1 { class Client { public void ClientMain () { Facade.Operation1(); Facade.Operation2(); } } static void Main() { new Client().ClientMain(); }} /* Output:Operation 1Subsystem A, Method A1Subsyste... 阅读全文
posted @ 2012-05-14 20:35
ChaunceyHao
阅读(163)
评论(0)
推荐(0)
摘要:
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;} }... 阅读全文
posted @ 2012-05-14 20:34
ChaunceyHao
阅读(171)
评论(0)
推荐(0)
摘要:
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 ... 阅读全文
posted @ 2012-05-14 20:33
ChaunceyHao
阅读(157)
评论(0)
推荐(0)
摘要:
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... 阅读全文
posted @ 2012-05-14 20:32
ChaunceyHao
阅读(169)
评论(0)
推荐(0)
摘要:
using System;namespace Wrox.ProCSharp.Basics{ public enum TimeOfDay { Morning = 0, Afternoon = 1, Evening = 2 } class EnumExample { public static int Main() { WriteGreeting(TimeOfDay.Morning); return 0; } static void WriteGreeting(TimeOfDay timeOfDay) { switch(timeOfDay) { case TimeOfDa... 阅读全文
posted @ 2012-05-14 15:58
ChaunceyHao
阅读(106)
评论(0)
推荐(0)
摘要:
using System;namespace Wrox.ProCSharp.Basics{ class MainEntryPoint { static void Main(string[] args) { Console.WriteLine("Type in a string"); string input; input = Console.ReadLine(); if (input == "") { Console.WriteLine("You typed in an empty string"); } else if (input 阅读全文
posted @ 2012-05-14 15:48
ChaunceyHao
阅读(131)
评论(0)
推荐(0)
摘要:
using System;using Microsoft.Web.Administration;class Program{ static void Main(string[] args) { ServerManager mgr = new ServerManager(); ApplicationPool myAppPool = mgr.ApplicationPools.Add("MyAppPool"); myAppPool.AutoStart = true; myAppPool.Cpu.Action = ProcessorAction.KillW3wp; myAppPoo 阅读全文
posted @ 2012-05-14 15:46
ChaunceyHao
阅读(127)
评论(0)
推荐(0)
摘要:
// Title: Building ASP.NET Server Controls//// Chapter: 5 - Event-based Programming// File: PageCommand.cs// Written by: Dale Michalk and Rob Cameron//// Copyright ?2003, Apress L.P.using System;namespace ControlsBookLib.Ch05{ public enum PageDirection { Left = 0, Right = 1 } public delegate void Pa 阅读全文
posted @ 2012-05-14 00:33
ChaunceyHao
阅读(134)
评论(0)
推荐(0)
摘要:
// Title: Building ASP.NET Server Controls//// Chapter: 5 - Event-based Programming// File: LifecycleControl.cs// Written by: Dale Michalk and Rob Cameron//// Copyright ?2003, Apress L.P.using System;using System.Web.UI;using System.Collections.Specialized;using System.Diagnostics;namespace Controls 阅读全文
posted @ 2012-05-14 00:14
ChaunceyHao
阅读(136)
评论(0)
推荐(0)
浙公网安备 33010602011771号