public IController Create(RequestContext context, Type type)
		{
			Precondition.Require(context, () => Error.ArgumentNull("context"));
			Precondition.Require(type, () => Error.ArgumentNull("type"));

			return (IController)ServiceLocator.Instance.GetService(type);
		}
 protected virtual IController CreateController(
     RequestContext context, string controllerName)
 {
     Precondition.Require(context, () => Error.ArgumentNull("context"));
     Precondition.Defined(controllerName, () => Error.InvalidArgument("controllerName"));
     
     return GetControllerInstance(context, GetControllerType(controllerName));
 }
        protected override IHttpHandler GetHttpHandler(RequestContext context)
        {
            if (ValidateAccessRights && !UrlAuthorizationModule
                .CheckUrlAccessForPrincipal(_virtualPath, context.Context.User, 
                context.Context.Request.HttpMethod.ToString()))
                throw new HttpException(403, "Access denied.");

            return (BuildManager.CreateInstanceFromVirtualPath(_virtualPath, typeof(Page)) as IHttpHandler);
        }
        private IHttpHandler GetHttpHandlerInternal(RequestContext context)
        {
            IHttpHandler handler = GetHttpHandler(context);
            IRoutableHttpHandler rh = (handler as IRoutableHttpHandler);
            if (rh != null)
                rh.RequestContext = context;

            return handler;
        }
		protected virtual IAsyncResult BeginExecute(RequestContext context, 
			AsyncCallback callback, object state)
		{
			Precondition.Require(context, () => Error.ArgumentNull("context"));

			VerifyExecuteCalledOnce();
			Initialize(context);

			return AsyncResultWrapper.Begin(callback, state, 
				OnBeginExecute, OnEndExecute, _executeTag);
		}
        protected virtual void ProcessRequest(HttpContextBase context)
        {
            RouteData data = Routes.GetRouteData(context);
            Precondition.Require(data, () => Error.NoRouteMatched());

            IRouteHandler handler = data.Handler;
            Precondition.Require(handler, () => Error.NoRouteHandlerFound());

            RequestContext ctx = new RequestContext(context, data);
            IHttpHandler httpHandler = handler.GetHttpHandler(ctx);
            Precondition.Require(httpHandler, () => Error.NoHttpHandlerFound(handler.GetType()));

            VerifyAndProcessRequest(httpHandler, context);
        }
 protected abstract IHttpHandler GetHttpHandler(RequestContext context);
示例#8
0
        /// <summary>
        /// Gets the <see cref="VirtualPathData"/> for 
        /// the current instance.
        /// </summary>
        /// <param name="value">The <see cref="ValueDictionary"/> 
        /// containing the route parameter values.</param>
		/// <param name="variables">The <see cref="ValueDictionary"/> 
		/// containing the route variable values.</param>
        public abstract VirtualPathData GetVirtualPath(RequestContext context, 
			ValueDictionary values, ValueDictionary variables);
 protected virtual void Initialize(RequestContext context)
 {
     Precondition.Require(context, () => Error.ArgumentNull("context"));
     _context = new ControllerContext(context, this);
 }
 void IController.Execute(RequestContext context)
 {
     Execute(context);
 }
        /// <summary>
        /// Finds the appropriate route for the specified 
        /// HTTP request and rewrites the execution path, 
        /// if necessary
        /// </summary>
        /// <param name="context">The current HTTP request context</param>
        public virtual void PostResolveRequestCache(HttpContextBase context)
        {
            RouteData data = Routes.GetRouteData(context);
            if (data == null)
                return;

            IRouteHandler handler = data.Handler;

            if (handler == null)
                throw Error.NoRouteHandlerFound();

            if (handler is StopRoutingHandler) // если надо тормознуть, тормозим
                return;

            RequestContext requestContext = new RequestContext(context, data);
            IHttpHandler httpHandler = handler.GetHttpHandler(requestContext);

            if (httpHandler == null)
                throw Error.NoHttpHandlerFound(handler.GetType());

            context.Items[_requestDataKey] =
                new RequestData(httpHandler, context.Request.Path);

            context.RewritePath("~/wahha.routing.axd");
        }
 protected virtual IHttpHandler GetHttpHandler(RequestContext context)
 {
     throw new NotSupportedException();
 }
示例#13
0
		public override VirtualPathData GetVirtualPath(RequestContext context, 
			ValueDictionary values, ValueDictionary variables)
		{
			return null;
		}
 internal static RequestContext GetRequestContext(RequestContext context)
 {
     Precondition.Require(context, () => Error.ArgumentNull("context"));
     return context;
 }
		protected override IHttpHandler GetHttpHandler(RequestContext context)
		{
			return new MvcAsyncHandler(context);
		}
 IController IControllerFactory.CreateController(
     RequestContext context, string controllerName)
 {
     return CreateController(context, controllerName);
 }
 public ControllerContext(RequestContext context, ControllerBase controller)
     : this(ControllerContext.GetRequestContext(context).Context, 
     ControllerContext.GetRequestContext(context).RouteData, controller)
 {
 }
		IAsyncResult IAsyncController.BeginExecute(
			RequestContext context, AsyncCallback callback, object state)
		{
			return BeginExecute(context, callback, state);
		}
        protected virtual IController GetControllerInstance(RequestContext context, Type type)
        {
            Precondition.Require(type, () => Error.ArgumentNull("type"));

            if (!typeof(IController).IsAssignableFrom(type))
                throw Error.InvalidControllerType(type.Name);

			return Activator.Create(context, type);
        }
		public MvcAsyncHandler(RequestContext context)
			: base(context)
		{
		}
示例#21
0
 public ViewContext(RequestContext context, ControllerBase controller, 
     IView view, ViewDataDictionary viewData, TempDataDictionary tempData)
     : this(GetRequestContext(context).Context, GetRequestContext(context).RouteData, 
     controller, view, viewData, tempData)
 {
 }
示例#22
0
 public MvcHandler(RequestContext context)
 {
     Precondition.Require(context, () => Error.ArgumentNull("context"));
     _context = context;
 }
示例#23
0
        /// <summary>
        /// Gets the <see cref="VirtualPathData"/> for 
        /// the current instance.
        /// </summary>
        /// <param name="values">The <see cref="ValueDictionary"/> 
        /// containing the route parameter values.</param>
		/// <param name="variables">The <see cref="ValueDictionary"/> 
		/// containing the route variable values.</param>
        public override VirtualPathData GetVirtualPath(RequestContext context,
			ValueDictionary values, ValueDictionary variables)
        {
            Precondition.Require(context, () => Error.ArgumentNull("context"));
            HttpContextBase httpContext = context.Context;
            HttpRequestBase request = httpContext.Request;

            BoundUrl url = _parsedRoute.Bind(context.RouteData.Values, values, variables, Defaults);
            if (url == null)
                return null;
            
            if (!MatchConstraints(httpContext, url.Values, RouteDirection.UrlGeneration))
                return null;

            string appRelativePath = url.Url;
            string applicationPath = GetApplicationPath(httpContext);
			string scheme = DetermineUriScheme(httpContext, SecureConnection);

            string virtualPath = (_parsedRoute.IsAppRelative) 
				? httpContext.Response.ApplyAppPathModifier(String.Concat(applicationPath, appRelativePath)) 
				: appRelativePath;

            string absolutePath = (_parsedRoute.IsRelative) 
				? String.Concat(scheme, Uri.SchemeDelimiter, request.Url.Authority, virtualPath) 
				: String.Concat(scheme, Uri.SchemeDelimiter, virtualPath);

            VirtualPathData data = new VirtualPathData(this, absolutePath);

			if (_tokens != null)
			{
				foreach (KeyValuePair<string, object> kvp in _tokens)
					data.Tokens[kvp.Key] = kvp.Value;
			}
            return data;
        }
 protected virtual IHttpHandler GetHttpHandler(RequestContext context)
 {
     return new MvcHandler(context);
 }
 protected override IHttpHandler GetHttpHandler(RequestContext context)
 {
     return(Factory());
 }
 IHttpHandler IRouteHandler.GetHttpHandler(RequestContext context)
 {
     return GetHttpHandler(context);
 }
        protected void Execute(RequestContext context)
        {
            Precondition.Require(context, () => Error.ArgumentNull("context"));

			VerifyExecuteCalledOnce();
            Initialize(context);
            ProcessRequest();
        }