Calyptus.Mvc.ControllerBaseAttribute.SerializeToPath C# (CSharp) Method

SerializeToPath() public method

public SerializeToPath ( IRouteAction action, IPathStack path ) : void
action IRouteAction
path IPathStack
return void
		public virtual void SerializeToPath(IRouteAction action, IPathStack path)
		{
			// TODO: child action binding

			if (_handlers == null) return;

			IPathStack bestStack = null;
			foreach (ActionHandler handler in _handlers)
			{
				if (handler.Action == action.Method)
				{
					IPathStack trialStack = new PathStack(false);
					handler.Binding.SerializePath(trialStack, action.Parameters);

					if (action.ChildAction != null)
					{
						if (!(handler is ParentActionHandler)) throw new BindingException("Method is not a parent action and can't handle further calls.");
					}
					else
					{
						if (handler is ParentActionHandler) throw new BindingException("Method is a parent action. You should add the default sub-action.");
					}

					if (trialStack.Index == 0) trialStack.TrailingSlash = !DisableTrailingSlash;

					if (bestStack == null || trialStack.Index > bestStack.Index || (trialStack.Index == bestStack.Index && trialStack.QueryString.Count > bestStack.QueryString.Count))
						bestStack = trialStack;
				}
			}
			if (bestStack != null)
			{
				path.Push(bestStack);
			}
			else
				throw new BindingException(String.Format("Method \"{0}\" is not bindable.", action.Method.Name));
		}
	}