27 lines
695 B
C#
27 lines
695 B
C#
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;
|
||
}
|
||
} |