public RouteAction(Type controllerType, MethodInfo method, object[] parameters, RouteAction childAction) { ControllerType = controllerType; Method = method; Parameters = parameters; ChildAction = childAction; }
void IEntryControllerBinding.SerializeToPath(IRouteAction action, IPathStack path) { if (Mappings != null) foreach (IMappingBinding mapping in this.Mappings) mapping.SerializeToPath(path); base.SerializeToPath(action, path); }
protected async Task WhenAction <T>(IRouteAction action, Func <T, Task> operation) where T : class, IRouteAction { var convertedAction = action as T; if (convertedAction != null) { await operation(convertedAction); } }
private async Task HandleRouteNavigationAsync(IRouteAction action, Transition transition, bool shouldCloseAppIfNeeded) { await WhenAction <NavigateRouteAction>(action, async n => { if (Navigator.Peek() != transition) { await Navigator.PushAsync(transition); } }); await WhenAction <NavigateBackWhileRouteAction>(action, async n => { while (Navigator.TransitionStack.Count > 0 && n.GoBackWhile(Navigator.Peek())) { await this.BackAsync(shouldCloseAppIfNeeded); } }); }
private void SerializePath(IRouteAction action, IPathStack path, bool requireEntry) { IControllerBinding[] bindings = GetControllerBindings(action.ControllerType); if (bindings == null || bindings.Length == 0) throw new BindingException(String.Format("Type \"{0}\" is not bindable.", action.ControllerType.FullName)); IPathStack bestStack = null; foreach (IControllerBinding b in bindings) if (!requireEntry || b is IEntryControllerBinding) { IPathStack trialStack = new PathStack(false); if (requireEntry) ((IEntryControllerBinding)b).SerializeToPath(action, trialStack); else b.SerializeToPath(action, trialStack); IRouteAction childAction = action.ChildAction; if (childAction != null) { SerializePath(childAction, trialStack, false); } 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("Type \"{0}\" is not a bindable EntryController.", action.ControllerType.FullName)); }
public void SerializeRelativePath(IRouteAction action, IPathStack path) { SerializePath(action, path, false); }
public void SerializeAbsoutePath(IRouteAction action, IPathStack path) { SerializePath(action, path, true); }
private async Task HandleRoutePresentation(IRouteAction action, Transition transition) { await WhenAction <PresentRouteAction>(action, async p => { await PresentAsync(p, transition); }); }
private async Task HandleRouteActionAsync(IRouteAction action, Transition transition, bool shouldCloseAppIfNeeded) { await HandleRouteNavigationAsync(action, transition, shouldCloseAppIfNeeded); await HandleRoutePresentation(action, transition); }
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)); }
public override void SerializeToPath(IRouteAction action, IPathStack path) { }