2016-08-25 15:09:51 +02:00
|
|
|
|
using System.IO;
|
|
|
|
|
|
using Umbraco.Core.IO;
|
2016-10-07 14:34:55 +02:00
|
|
|
|
using Umbraco.Core.Logging;
|
2016-08-25 15:09:51 +02:00
|
|
|
|
using Umbraco.Core.Manifest;
|
|
|
|
|
|
|
2018-08-29 01:15:46 +10:00
|
|
|
|
namespace Umbraco.Core.Components
|
2016-08-25 15:09:51 +02:00
|
|
|
|
{
|
2016-10-07 14:34:55 +02:00
|
|
|
|
[RuntimeLevel(MinLevel = RuntimeLevel.Run)]
|
2016-08-25 15:09:51 +02:00
|
|
|
|
public class ManifestWatcherComponent : UmbracoComponentBase, IUmbracoCoreComponent
|
|
|
|
|
|
{
|
|
|
|
|
|
// if configured and in debug mode, a ManifestWatcher watches App_Plugins folders for
|
|
|
|
|
|
// package.manifest chances and restarts the application on any change
|
|
|
|
|
|
private ManifestWatcher _mw;
|
|
|
|
|
|
|
2016-10-07 14:34:55 +02:00
|
|
|
|
public void Initialize(IRuntimeState runtime, ILogger logger)
|
2016-08-25 15:09:51 +02:00
|
|
|
|
{
|
2016-10-07 14:34:55 +02:00
|
|
|
|
if (runtime.Debug == false) return;
|
2016-08-25 15:09:51 +02:00
|
|
|
|
|
|
|
|
|
|
//if (ApplicationContext.Current.IsConfigured == false || GlobalSettings.DebugMode == false)
|
|
|
|
|
|
// return;
|
|
|
|
|
|
|
|
|
|
|
|
var appPlugins = IOHelper.MapPath("~/App_Plugins/");
|
|
|
|
|
|
if (Directory.Exists(appPlugins) == false) return;
|
|
|
|
|
|
|
2016-10-07 14:34:55 +02:00
|
|
|
|
_mw = new ManifestWatcher(logger);
|
2016-08-25 15:09:51 +02:00
|
|
|
|
_mw.Start(Directory.GetDirectories(appPlugins));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override void Terminate()
|
|
|
|
|
|
{
|
|
|
|
|
|
_mw?.Dispose();
|
|
|
|
|
|
_mw = null;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2017-07-20 11:21:28 +02:00
|
|
|
|
}
|