-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- FileSystemWatcherExtension added - FileSystem get last write date added
- Loading branch information
Showing
4 changed files
with
106 additions
and
5 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
42 changes: 42 additions & 0 deletions
42
Core.Common.Standard/Extension/FileSystemWatcherExtension.cs
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,42 @@ | ||
using System.IO; | ||
|
||
namespace KY.Core.Extension; | ||
|
||
public static class FileSystemWatcherExtension | ||
{ | ||
public static FileSystemWatcher OnChanged(this FileSystemWatcher watcher, FileSystemEventHandler handler) | ||
{ | ||
watcher.Changed += handler; | ||
return watcher; | ||
} | ||
|
||
public static FileSystemWatcher OnCreated(this FileSystemWatcher watcher, FileSystemEventHandler handler) | ||
{ | ||
watcher.Created += handler; | ||
return watcher; | ||
} | ||
|
||
public static FileSystemWatcher OnDeleted(this FileSystemWatcher watcher, FileSystemEventHandler handler) | ||
{ | ||
watcher.Deleted += handler; | ||
return watcher; | ||
} | ||
|
||
public static FileSystemWatcher OnRenamed(this FileSystemWatcher watcher, RenamedEventHandler handler) | ||
{ | ||
watcher.Renamed += handler; | ||
return watcher; | ||
} | ||
|
||
public static FileSystemWatcher OnError(this FileSystemWatcher watcher, ErrorEventHandler handler) | ||
{ | ||
watcher.Error += handler; | ||
return watcher; | ||
} | ||
|
||
public static FileSystemWatcher IncludeSubdirectories (this FileSystemWatcher watcher) | ||
{ | ||
watcher.IncludeSubdirectories = true; | ||
return watcher; | ||
} | ||
} |