Ejemplo n.º 1
0
        private HttpHandlerCollection RegisterHandlers()
        {
            var handlers = new HttpHandlerCollection();

            // регистрируем обработчики для методов плагинов
            foreach (var action in RequestReceived)
            {
                Logger.Info("Register HTTP handler (API): '{0}'", action.Metadata.Url);

                var handler = new ApiListenerHandler(action.Value);
                handlers.RegisterHandler(action.Metadata.Url, handler);
            }

            // регистрируем обработчики для ресурсов
            foreach (Plugin plugin in Context.GetAllPlugins())
            {
                Type type = plugin.GetType();
                var attributes = type.GetCustomAttributes<HttpResourceAttribute>();

                foreach (var attribute in attributes)
                {
                    Logger.Info("Register HTTP handler (resource): '{0}'", attribute.Url);

                    var resHandler = new ResourceListenerHandler(
                        type.Assembly, attribute.ResourcePath, attribute.ContentType);

                    handlers.RegisterHandler(attribute.Url, resHandler);
                }
            }

            return handlers;
        }
Ejemplo n.º 2
0
 public DependencyResolver(HttpHandlerCollection handlers, Logger logger)
 {
     this.handlers = handlers;
     this.logger = logger;
 }
Ejemplo n.º 3
0
 public CommonController(HttpHandlerCollection handlers, Logger logger)
 {
     this.handlers = handlers;
     this.logger = logger;
 }