2022-11-06 23:03:52 +08:00
|
|
|
|
namespace Dipper.Alioth.Extensions;
|
|
|
|
|
|
|
|
|
|
public static class StartHostExtension
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 添加监听服务文件夹组件
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="host"></param>
|
|
|
|
|
/// <returns></returns>
|
2022-11-09 22:06:06 +08:00
|
|
|
|
public static WebStarHost AddWatchServiceFolder(this WebStarHost host, string path)
|
2022-11-06 23:03:52 +08:00
|
|
|
|
{
|
|
|
|
|
if (!Directory.Exists(path))
|
|
|
|
|
{
|
|
|
|
|
throw new DirectoryNotFoundException(path);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 这块地方应当是另一个类的
|
|
|
|
|
// 且该类应当依赖注入(单例注入)至Host主机中
|
|
|
|
|
var watcher = new FileSystemWatcher(path);
|
|
|
|
|
watcher.EnableRaisingEvents = true;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return host;
|
|
|
|
|
}
|
|
|
|
|
}
|