- 博客(14)
- 资源 (5)
- 收藏
- 关注
转载 Environment.SpecialFolder Enumeration
Differences between the Windows versionsXP/Server 2003ApplicationData: C:/Documents and Settings//Application DataCommonApplicationData: C:/Documents and Settings/All Users/Application DataCommonProgramFiles: C:/Program Files/Common FilesDesktopDirectory:
2011-05-31 10:32:00 477
原创 Flyweight Design
<br />用来支持大量重复的数据的存储,比如很多相同的图元要存储在不同的图片/文档。<br />1)Flyweight:能对extrinsic state(外在状态)接收 和相应的接口。<br /> <br />public abstract class Flyweight<br /> {<br /> public abstract void Operation(int extrinsicState);<br /> }<br />2) ConcereteFlyweight:实现F
2011-05-30 11:02:00 430
原创 JavaScript: How to detect that the Internet Connection is foffline
<br /><br />There are a number of ways to do this:AJAX request to your own website. If that request fails, there's a good chance it's the connection at fault. The JQuerydocumentation has a section on handling failed AJAX requests. Beware of the Same Origin
2011-05-23 12:49:00 487
原创 How to assign control right to specific folder
<br /><br />using System.Security.AccessControl;<br /> private void ApplyFullControlRight(string folder)<br /> {<br /> if (Directory.Exists(folder))<br /> {<br /> DirectoryInfo myDirectoryInfo = new Direct
2011-05-23 12:45:00 473
原创 How to create short-cut dynamically
<br /><br />using IWshRuntimeLibrary;<br />string profileNewFileName = Path.Combine(shortCutPath, @"short-cut.lnk");<br /> if (File.Exists(profileNewFileName))<br /> {<br /> File.Delete(profileNewFileName);<
2011-05-23 12:44:00 444
原创 How to check Win7 or 64bit environment
<br /><br />private static string ProgramFilesx86()<br /> {<br /> if (8 == IntPtr.Size<br /> || (!String.IsNullOrEmpty(Environment.GetEnvironmentVariable("PROCESSOR_ARCHITEW6432"))))<br /> {<br />
2011-05-23 12:40:00 655
原创 How to simulate Mouse Click event
<br /><br />[DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]<br /> public static extern void mouse_event(long dwFlags, long dx, long dy, long cButtons, long dwExtraInfo);<br /> <br /> private co
2011-05-23 12:36:00 718
原创 Facade Design
<br />为一个子系统提供统一的接口;<br />1.Subsystem的类<br /><br />class SubSystemOne<br /> {<br /> public void MethodOne()<br /> {<br /> Console.WriteLine(" SubSystemOne Method");<br /> }<br /> }<br /><br />class SubSystemTwo<br /> {<br /> public void
2011-05-11 16:53:00 514
原创 Decorator Design
<br />对基类的已有功能的扩展,不通过继承的方式来实现。<br />1.Component:<br />对已有对象的允许扩展的功能进行接口定义<br /><br />public abstract class Component2<br /> {<br /> //允许Decorator/子类动态修改的接口<br /> public abstract void Operation();<br /> }2.ConcreteComponentComponent的子类实现publ
2011-05-10 14:25:00 470
原创 Composite
<br />部分和整体的关系,允许客户以统一的方式来访问对象;<br />1.Component<br />-提供统一管理Childen的接,Add/Remove<br />-统一的操作接口Operation<br /><br />public abstract class Component<br /> {<br /> protected string _name;<br /> public Component(string name)<br /> {<br
2011-05-09 13:43:00 520
原创 Bridge Design
<br />可以把类接口的定义和实现进行分离;<br />1. Abstraction<br />-BusinessObject的接口定义,比Implementor的层次高<br /> <br />-包含ConcreteImplemtator的引用<br /> <br /><br />public abstract class Abstraction<br /> {<br /> protected Implementor _implementor;<br /> <br />
2011-05-09 12:54:00 387
原创 Adapter Design
把已经实现类的接口转化为客户端可以接受的接口,解决不同类的接口兼容问题。1.Target:客户端所需要的业务逻辑的接口public interface Target { void Request(); }2.Adaptee:对已经存在的类,定义接口。public class Adaptee { public void SpecificRequest() { return; } }3.Adapter:把Ada
2011-05-06 12:53:00 440
原创 Prototype Design
通过Clone/序列化的方法来创建对象.1.Prototype:包含Clone抽象接口public interface IPrototype2 { IPrototype2 Clone(); }2.ConcretePrototype:实现Prototype的接口public class ConcretePrototype : IPrototype2 { public IPrototype2 Clone() { return th
2011-05-04 12:38:00 541
原创 Builder Design
<br />允许修改产品的内部表示,同时也隐藏的装配产品的细节。<br />每个特定的生成器都是独立的。类似抽象工厂,返回有许多方法和对象组成的类,抽象工厂返回的是相关的产品类;<br />而生成器则是根据它的数据一步一步一的构建复杂的对象。<br />把复杂对象的生成从构造函数中分离出来。<br /> <br />1.Director:使用Builder来生成对象<br /><br />public class Director<br /> {<br /> public void Cr
2011-05-04 12:28:00 516
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人