-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1. 代码生成器客户端配置新增 Microfrontend 属性,用于控制是否启用微前端模板.
2. 随机数辅助操作类 Util.Helpers.Random 新增 GetValues 方法, 用于从集合中随机获取指定数量子集. 3. 新增Razor页面监听服务 IRazorWatchService 及相关类型,用于监视Razor页面更改时自动生成Html文件. 4. 修复表格组件复选框,单选框,序号在有合并表头的情况下显示不正确的错误.
- Loading branch information
Showing
112 changed files
with
1,897 additions
and
228 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,203 @@ | ||
namespace Util.Helpers; | ||
|
||
/// <summary> | ||
/// 文件监视器 | ||
/// </summary> | ||
public class FileWatcher : IDisposable { | ||
/// <summary> | ||
/// 文件系统监视器 | ||
/// </summary> | ||
private readonly FileSystemWatcher _watcher; | ||
|
||
/// <summary> | ||
/// 初始化文件监视器 | ||
/// </summary> | ||
public FileWatcher() { | ||
_watcher = new FileSystemWatcher(); | ||
_watcher.NotifyFilter = NotifyFilters.LastWrite | NotifyFilters.FileName | NotifyFilters.DirectoryName; | ||
} | ||
|
||
/// <summary> | ||
/// 设置监听目录路径 | ||
/// </summary> | ||
/// <param name="path">目录绝对路径</param> | ||
/// <param name="includeSubdirectories">是否监听子目录,默认值: true</param> | ||
public FileWatcher Path( string path, bool includeSubdirectories = true ) { | ||
_watcher.Path = path; | ||
_watcher.IncludeSubdirectories = includeSubdirectories; | ||
return this; | ||
} | ||
|
||
/// <summary> | ||
/// 设置监听通知过滤 | ||
/// </summary> | ||
/// <param name="notifyFilters">监听通知过滤</param> | ||
public FileWatcher NotifyFilter( NotifyFilters notifyFilters ) { | ||
_watcher.NotifyFilter = notifyFilters; | ||
return this; | ||
} | ||
|
||
/// <summary> | ||
/// 设置过滤模式 | ||
/// </summary> | ||
/// <param name="filter">过滤模式,默认值: *.* ,范例: *.cshtml 可过滤cshtml文件</param> | ||
public FileWatcher Filter( string filter ) { | ||
_watcher.Filter = filter; | ||
return this; | ||
} | ||
|
||
/// <summary> | ||
/// 处理文件创建监听事件 | ||
/// </summary> | ||
/// <param name="action">文件创建监听事件处理器</param> | ||
public FileWatcher OnCreated( Action<object, FileSystemEventArgs> action ) { | ||
_watcher.Created += ( source, e ) => { | ||
action( source, e ); | ||
}; | ||
return this; | ||
} | ||
|
||
/// <summary> | ||
/// 处理文件创建监听事件 | ||
/// </summary> | ||
/// <param name="action">文件创建监听事件处理器</param> | ||
public FileWatcher OnCreatedAsync( Func<object, FileSystemEventArgs, Task> action ) { | ||
_watcher.Created += async ( source, e ) => { | ||
await action( source, e ); | ||
}; | ||
return this; | ||
} | ||
|
||
/// <summary> | ||
/// 处理文件变更监听事件 | ||
/// </summary> | ||
/// <param name="action">文件变更监听事件处理器</param> | ||
public FileWatcher OnChanged( Action<object, FileSystemEventArgs> action ) { | ||
_watcher.Changed += ( source, e ) => { | ||
action( source, e ); | ||
}; | ||
return this; | ||
} | ||
|
||
/// <summary> | ||
/// 处理文件变更监听事件 | ||
/// </summary> | ||
/// <param name="action">文件变更监听事件处理器</param> | ||
public FileWatcher OnChangedAsync( Func<object, FileSystemEventArgs, Task> action ) { | ||
_watcher.Changed += async ( source, e ) => { | ||
await action( source, e ); | ||
}; | ||
return this; | ||
} | ||
|
||
/// <summary> | ||
/// 处理文件删除监听事件 | ||
/// </summary> | ||
/// <param name="action">文件删除监听事件处理器</param> | ||
public FileWatcher OnDeleted( Action<object, FileSystemEventArgs> action ) { | ||
_watcher.Deleted += ( source, e ) => { | ||
action( source, e ); | ||
}; | ||
return this; | ||
} | ||
|
||
/// <summary> | ||
/// 处理文件删除监听事件 | ||
/// </summary> | ||
/// <param name="action">文件删除监听事件处理器</param> | ||
public FileWatcher OnDeletedAsync( Func<object, FileSystemEventArgs, Task> action ) { | ||
_watcher.Deleted += async ( source, e ) => { | ||
await action( source, e ); | ||
}; | ||
return this; | ||
} | ||
|
||
/// <summary> | ||
/// 处理文件重命名监听事件 | ||
/// </summary> | ||
/// <param name="action">文件重命名监听事件处理器</param> | ||
public FileWatcher OnRenamed( Action<object, RenamedEventArgs> action ) { | ||
_watcher.Renamed += ( source, e ) => { | ||
action( source, e ); | ||
}; | ||
return this; | ||
} | ||
|
||
/// <summary> | ||
/// 处理文件重命名监听事件 | ||
/// </summary> | ||
/// <param name="action">文件重命名监听事件处理器</param> | ||
public FileWatcher OnRenamedAsync( Func<object, RenamedEventArgs, Task> action ) { | ||
_watcher.Renamed += async ( source, e ) => { | ||
await action( source, e ); | ||
}; | ||
return this; | ||
} | ||
|
||
/// <summary> | ||
/// 处理文件错误监听事件 | ||
/// </summary> | ||
/// <param name="action">文件错误监听事件处理器</param> | ||
public FileWatcher OnError( Action<object, ErrorEventArgs> action ) { | ||
_watcher.Error += ( source, e ) => { | ||
action( source, e ); | ||
}; | ||
return this; | ||
} | ||
|
||
/// <summary> | ||
/// 处理文件错误监听事件 | ||
/// </summary> | ||
/// <param name="action">文件错误监听事件处理器</param> | ||
public FileWatcher OnErrorAsync( Func<object, ErrorEventArgs, Task> action ) { | ||
_watcher.Error += async ( source, e ) => { | ||
await action( source, e ); | ||
}; | ||
return this; | ||
} | ||
|
||
/// <summary> | ||
/// 处理文件监听器释放事件 | ||
/// </summary> | ||
/// <param name="action">文件监听器释放事件处理器</param> | ||
public FileWatcher OnDisposed( Action<object, EventArgs> action ) { | ||
_watcher.Disposed += ( source, e ) => { | ||
action( source, e ); | ||
}; | ||
return this; | ||
} | ||
|
||
/// <summary> | ||
/// 处理文件监听器释放事件 | ||
/// </summary> | ||
/// <param name="action">文件监听器释放事件处理器</param> | ||
public FileWatcher OnDisposedAsync( Func<object, EventArgs, Task> action ) { | ||
_watcher.Disposed += async ( source, e ) => { | ||
await action( source, e ); | ||
}; | ||
return this; | ||
} | ||
|
||
/// <summary> | ||
/// 启动监听 | ||
/// </summary> | ||
public FileWatcher Start() { | ||
_watcher.EnableRaisingEvents = true; | ||
return this; | ||
} | ||
|
||
/// <summary> | ||
/// 停止监听 | ||
/// </summary> | ||
public FileWatcher Stop() { | ||
_watcher.EnableRaisingEvents = false; | ||
return this; | ||
} | ||
|
||
/// <summary> | ||
/// 释放 | ||
/// </summary> | ||
public void Dispose() { | ||
_watcher?.Dispose(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.