1public interface IHttpHandlerFactory
2{
3 // Methods
4 IHttpHandler GetHandler(HttpContext context, string requestType, string url, string pathTranslated);
5 void ReleaseHandler(IHttpHandler handler);
6}
7
IHttpHandlerFactory.GetHandler是一個工廠方法模式的典型例子,在這個應用中,各個角色的設置如下:
抽象工廠角色:IHttpHandlerFactory
具體工廠角色:PageHandlerFactory
抽象產品角色:IHttpHandler
具體產品角色:ASP.SamplePage_aspx
進一步去理解
理解上面所說的之后,我們就可以去自定義工廠類來對特定的資源類型進行處理。第一步我們需要創建兩個類去分別實現IHttpHandlerFactory 和IHttpHandler這兩個接口。
1public class HttpHandlerFactoryImpl:IHttpHandlerFactory {
2
3 IHttpHandler IHttpHandlerFactory.GetHandler(
4 HttpContext context, String requestType,
延伸閱讀
文章來源于領測軟件測試網 http://www.kjueaiud.com/