Update: Plugin Web Helpers

Web Helpers included in UI Extensions and WebHandlers
This commit is contained in:
Gary Sharp
2013-10-22 13:48:25 +11:00
parent cc218a08e4
commit 0d60fb422c
7 changed files with 166 additions and 130 deletions
@@ -13,26 +13,26 @@ namespace Disco.Services.Plugins.Features.UIExtension
public abstract class UIExtensionFeature<UIModel> : PluginFeature where UIModel : BaseUIModel
{
public ControllerContext Context { get; set; }
private Lazy<WebHelper> plugin;
protected WebHelper Plugin
{
get
{
return plugin.Value;
}
}
public UIExtensionFeature()
{
this.plugin = new Lazy<WebHelper>(new Func<WebHelper>(() => {
if (this.Context == null)
throw new InvalidOperationException("The Context property is not initialized");
return new WebHelper(this.Context.HttpContext, this.Manifest.PluginManifest);
}));
}
public abstract UIExtensionResult ExecuteAction(ControllerContext context, UIModel model);
#region Bundles
public void IncludeStyleSheet(string Resource)
{
if (this.Context == null)
throw new NullReferenceException("This method can only be called when a Context is available");
this.Context.HttpContext.IncludeStyleSheetResource(Resource, this.Manifest.PluginManifest);
}
public void IncludeScript(string Resource)
{
if (this.Context == null)
throw new NullReferenceException("This method can only be called when a Context is available");
this.Context.HttpContext.IncludeScriptResource(Resource, this.Manifest.PluginManifest);
}
#endregion
#region ActionResults
protected LiteralResult Literal(string Content)