Dipper/Dipper.Alioth/Extensions/StartHostExtension.cs

27 lines
695 B
C#
Raw Normal View History

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