Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. using System;
  2. using System.Web;
  3. using System.Web.UI;
  4.  
  5. namespace lib.ioc.di
  6. {
  7.  
  8.     public class SimpleInjectorPageHandlerFactory : PageHandlerFactory
  9.     {
  10.  
  11.         public override IHttpHandler GetHandler(HttpContext context, string requestType, string virtualPath, string path)
  12.         {
  13.             var handler = base.GetHandler(context, requestType, virtualPath, path);
  14.             if (handler != null && handler is IPage)
  15.             {
  16.                 IPage page = handler as IPage;
  17.                 //all the reources will be injected here.
  18.                 page.Resource = new Resource(
  19.                     String.Format("The owner of this resource is an instance of the class {0}",
  20.                                   page.GetType().Name));
  21.             }
  22.             return handler;
  23.         }
  24.  
  25.     }
  26.  
  27. }
  28.