Files
Disco/Disco.Services/Plugins/PluginWebViewPage.cs
T
Gary Sharp bc08bd7dc2 Fix #22: PluginWebViewPage ReferenceNullException
Plugin Helper needs to be lazy loaded
2013-10-31 16:44:20 +11:00

36 lines
957 B
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Disco.Services.Plugins
{
public abstract class PluginWebViewPage<T> : Disco.Services.Web.WebViewPage<T>
{
private Lazy<WebPageHelper<T>> _plugin;
public PluginManifest Manifest {get;private set;}
public WebPageHelper<T> Plugin
{
get
{
return _plugin.Value;
}
}
public PluginWebViewPage()
{
var self = this.GetType();
this.Manifest = Plugins.GetPlugin(self.Assembly);
this._plugin = new Lazy<WebPageHelper<T>>(() => {
if (this.Context == null)
throw new InvalidOperationException("The WebViewPage Context property is not initialized");
return new WebPageHelper<T>(this, this.Manifest);
});
}
}
}