1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
|
using System;
using System.ComponentModel.Composition;
using System.Threading.Tasks;
using Microsoft.WebMatrix.Extensibility;
namespace NuGet.WebMatrix
{
[Export(typeof(Extension))]
[Export(typeof(NuGetExtension))]
internal class NuGetExtension : Extension
{
/// <summary>
/// Initializes a new instance of the <see cref="T:NuGetExtension"/> class.
/// </summary>
public NuGetExtension()
: base(Resources.ExtensionName)
{
}
public ModuleGlobals Globals
{
get;
private set;
}
public IWebMatrixHostInternal Host
{
get;
private set;
}
internal static TaskScheduler GetCurrentTaskScheduler()
{
TaskScheduler scheduler = null;
try
{
// the scheduler should be the current Sync Context
scheduler = TaskScheduler.FromCurrentSynchronizationContext();
}
catch (InvalidOperationException)
{
scheduler = TaskScheduler.Default;
}
return scheduler;
}
protected override void Initialize(IWebMatrixHost host, ExtensionInitData initData)
{
this.Host = (IWebMatrixHostInternal)host;
this.Globals = new ModuleGlobals(this.Host, this.Host.ServiceProvider);
this.Host.WebSiteChanged += this.Host_WebSiteChanged;
}
private void Host_WebSiteChanged(object sender, EventArgs e)
{
NuGetModel.ClearCache();
}
}
}
|