GetHandler() public static method

Gets the IDashboardHandler mapped to the route identified by the given verb and handler-relative URL.
public static GetHandler ( string verb, string handlerRelativeUrl, IRepositoryFactory repositoryFactory ) : IDashboardHandler
verb string The verb to get the handler for.
handlerRelativeUrl string The handler-relative URL to get the handler for.
repositoryFactory IRepositoryFactory The repository factory to use when instantiating the handler.
return IDashboardHandler
Example #1
0
        public IHttpHandler GetHandler(HttpContextBase context, string requestType, string url, string pathTranslated)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context", "context cannot be null.");
            }

            requestType = requestType ?? "GET";

            if (this.Mode == DashboardEnabledMode.On ||
                (this.Mode == DashboardEnabledMode.LocalOnly &&
                 context.Request.IsLocal))
            {
                string            handlerUrl         = ResolveHandlerUrl(this.HandlerUrl, context);
                string            handlerRelativeUrl = GetHandlerRelativeUrl(handlerUrl, context.Request.RawUrl);
                QueryString       queryString        = QueryString.FromUrl(context.Request.Url);
                IDashboardHandler handler            = DashboardRouter.GetHandler(requestType, handlerRelativeUrl, this.RepositoryFactory);

                if (handler != null)
                {
                    handler.ApplicationName           = this.ApplicationName;
                    handler.HandlerUrl                = handlerUrl;
                    handler.HandlerRelativeRequestUrl = handlerRelativeUrl;
                    handler.QueryString               = queryString;
                    handler.Verb = requestType.ToUpperInvariant();
                }
                else
                {
                    context.Response.StatusCode = 404;
                    context.Response.End();
                }

                return(handler);
            }
            else
            {
                context.Response.StatusCode = 403;
                context.Response.End();
            }

            return(null);
        }