SanSYS

Untitled

Mar 10th, 2015
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.74 KB | None | 0 0
  1. public class MyImageHandler : IHttpHandler
  2. {
  3.     RequestContext _requestContext;
  4.  
  5.     public MyImageHandler(RequestContext requestContext,
  6.          // Other dependencies that the class needs
  7.         )
  8.     {
  9.         _requestHandler = requestHandler;
  10.         // Store other dependencies
  11.     }
  12.  
  13.     public void ProcessRequest(HttpContext context)
  14.     {
  15.         ...
  16.     }
  17. }
  18.  
  19. public class GenericRouteHandler<T> : IRouteHandler
  20.     where T : IHttpHandler
  21. {
  22.     public IHttpHandler(RequestContext requestContext)
  23.     {
  24.         return ObjectFactory.With(requestContext).GetInstance<T>();
  25.     }
  26. }
  27.  
  28. // Инициализация маршрута
  29. RouteTable.Routes.Add(new Route("Image/{ImageID}", new GenericRouteHandler<MyImageHandler>()));
Advertisement
Add Comment
Please, Sign In to add comment