Dipper/Dipper.Alioth/Extensions/StartHostExtension.cs

25 lines
675 B
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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