-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWatcherManager.cs
More file actions
90 lines (67 loc) · 2.16 KB
/
WatcherManager.cs
File metadata and controls
90 lines (67 loc) · 2.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
using System;
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Threading.Tasks;
namespace Howmet.Utilities.FileSystem
{
/// <summary>
/// Holds, initiates and manages a collection of FileWatchers.
/// </summary>
public class WatcherManager:FileSystemEventHandlers
{
#region Constants
#endregion
#region Declarations
List<string> Paths = new List<string>();
List<FileWatcher> Watchers = new List<FileWatcher>();
#endregion
#region Constructors
public WatcherManager(List<string> paths)
{
Paths = paths;
foreach (string path in Paths)
{
FileWatcher fileWatcher = new FileWatcher(path);
Watchers.Add(fileWatcher);
fileWatcher.MessageAvailable += FileWatcher_MessageAvailable;
fileWatcher.FileCreated += FileWatcher_FileCreated;
fileWatcher.FileDeleted += FileWatcher_FileDeleted;
fileWatcher.FileModified += FileWatcher_FileModified;
fileWatcher.FileRenamed += FileWatcher_FileRenamed;
}
}
#endregion
#region Event Handling
private void FileWatcher_MessageAvailable(object sender, MessageAvailableEventArgs e)
{
OnMessageAvailable(e);
}
private void FileWatcher_FileCreated(object sender, FileSystemEventArgs e)
{
OnFileCreated(e);
}
private void FileWatcher_FileModified(object sender, FileSystemEventArgs e)
{
OnFileModified(e);
}
private void FileWatcher_FileRenamed(object sender, RenamedEventArgs e)
{
OnFileRenamed(e);
}
private void FileWatcher_FileDeleted(object sender, FileSystemEventArgs e)
{
OnFileDeleted(e);
}
#endregion
#region Public Methods
public void ShutItDown()
{
foreach (FileWatcher watcher in Watchers)
{
watcher.Shutdown();
}
}
#endregion
}
}