Beispiel #1
0
 protected virtual void Redirect(IRedirectSupport redirecter, string area, string controller, string action,
                                 IDictionary parameters)
 {
     if (UseRouting)
     {
         redirecter.RedirectUsingRoute(area, controller, action, parameters);
     }
     else
     {
         redirecter.Redirect(area, controller, action, parameters);
     }
 }
		protected virtual void Redirect(IRedirectSupport redirecter, string area, string controller, string action,
		                                IDictionary parameters)
		{
			if (UseRouting)
			{
				redirecter.RedirectUsingRoute(area, controller, action, parameters);
			}
			else
			{
				redirecter.Redirect(area, controller, action, parameters);
			}
		}
Beispiel #3
0
        /// <summary>
        /// Performs a strongly typed redirect to an action of the <typeparamref name="TController"/>.
        /// <para />
        /// This must be a lamda in the form of <c>c => c.Action(optional, action, parameters)</c>,
        /// where the action parameters can be anything you want (variable, property, method call etc.)
        /// as long as they return the right parameter and the lambda function will compile.
        /// </summary>
        /// <typeparam name="TController">The type of the controller that has the action.</typeparam>
        /// <param name="self">The object that supports redirecting.</param>
        /// <param name="useRouting">If true, uses routing.</param>
        /// <param name="action">An expression that respresents the redirect in the form of a lambda function call.</param>
        public static void Redirect <TController>(
            this IRedirectSupport self, bool useRouting, Expression <Action <TController> > action)
            where TController : IController
        {
            AssertArguments(self, action);

            ActionMethodModel model = CreateModel(action);

            var redirecter = new ResponseRedirectInvoker
            {
                UseRouting = useRouting
            };

            redirecter.Redirect(self, model);
        }
Beispiel #4
0
 protected override void Redirect(IRedirectSupport redirecter, string area, string controller, string action,
                                  IDictionary parameters)
 {
     if (UseRouting)
     {
         base.Redirect(redirecter, area, controller, action, parameters);
     }
     else
     {
         if (redirecter != _controller)
         {
             throw new TypedActionException(
                       "The controller and the redirecter must be the same instance, but they are not. " +
                       "Controller = {0} and redirecter = {1}.", _controller, redirecter);
         }
         _controller.RedirectToAction(action, parameters);
     }
 }
		protected override void Redirect(IRedirectSupport redirecter, string area, string controller, string action,
		                                 IDictionary parameters)
		{
			if (UseRouting)
			{
				base.Redirect(redirecter, area, controller, action, parameters);
			}
			else
			{
				if (redirecter != _controller)
				{
					throw new TypedActionException(
						"The controller and the redirecter must be the same instance, but they are not. " +
						"Controller = {0} and redirecter = {1}.", _controller, redirecter);
				}
				_controller.RedirectToAction(action, parameters);
			}
		}
Beispiel #6
0
 public virtual void Redirect(IRedirectSupport redirecter, ActionMethodModel action)
 {
     Redirect(redirecter, action.Area, action.Controller, action.Action, action.GetParameterDictionary());
 }
Beispiel #7
0
 public static void Redirect <TController>(
     this IRedirectSupport self, Expression <Action <TController> > action)
     where TController : IController
 {
     Redirect(self, DefaultUseRouting, action);
 }
		public virtual void Redirect(IRedirectSupport redirecter, ActionMethodModel action)
		{
			Redirect(redirecter, action.Area, action.Controller, action.Action, action.GetParameterDictionary());
		}