Created
January 19, 2012 03:22
-
-
Save JakeGinnivan/1637534 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Linq.Expressions; | |
using System.Threading.Tasks; | |
using Phoenix; | |
using Phoenix.ActionResults; | |
using Phoenix.Framework; | |
using Phoenix.Navigation; | |
namespace Rtio.Cafe.ModuleContracts | |
{ | |
public interface IShortcut | |
{ | |
Task Execute(INavigationFrame targetFrame); | |
} | |
public abstract class ControllerActionShortcut<TController> : IShortcut where TController : Controller | |
{ | |
readonly IPhoenixApplication phoenixApplication; | |
protected ControllerActionShortcut(IPhoenixApplication phoenixApplication) | |
{ | |
this.phoenixApplication = phoenixApplication; | |
} | |
/// <summary> | |
/// Gets/Sets the Controller Action which should be invoked when executing this shortcut | |
/// </summary> | |
public abstract Expression<Func<TController, ActionResult>> ControllAction { get; } | |
public Task Execute(INavigationFrame targetFrame) | |
{ | |
return new InvokeActionBuilder<TController>(new ControllerActionContext(phoenixApplication)) | |
.InvokeAction(targetFrame, ControllAction); | |
} | |
} | |
public abstract class ControllerActionShortcut : IShortcut | |
{ | |
readonly IPhoenixApplication phoenixApplication; | |
protected ControllerActionShortcut(IPhoenixApplication phoenixApplication) | |
{ | |
this.phoenixApplication = phoenixApplication; | |
} | |
/// <summary> | |
/// Gets/Sets the Controller Action which should be invoked when executing this shortcut | |
/// </summary> | |
public abstract ControllerAction ControllAction { get; } | |
/// <summary> | |
/// Gets/Sets the Entry Point arguments for the application. | |
/// </summary> | |
public virtual IEnumerable<object> ControllerActionArguments | |
{ | |
get { return null; } | |
} | |
public Task Execute(INavigationFrame targetFrame) | |
{ | |
return new InvokeActionBuilder(new ControllerActionContext(phoenixApplication)) | |
.InvokeAction(targetFrame, ControllAction, | |
(ControllerActionArguments??Enumerable.Empty<object>()).ToArray()); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment