forked from pascalabcnet/pascalabcnet
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFSWatcherService.cs
More file actions
65 lines (59 loc) · 1.69 KB
/
FSWatcherService.cs
File metadata and controls
65 lines (59 loc) · 1.69 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
// Copyright (c) Ivan Bondarev, Stanislav Mikhalkovich (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace VisualPascalABC
{
class FSWatcherService
{
Dictionary<string, FileChangeWatcher> watchers = new Dictionary<string, FileChangeWatcher>();
public void AddWatcher(string FileName)
{
try
{
string s = FileName.ToLower();
if (!watchers.ContainsKey(s))
watchers[s] = new FileChangeWatcher(FileName);
}
catch
{
}
}
public void DisableWatcher(string FileName)
{
string s = FileName.ToLower();
FileChangeWatcher fcw = null;
if (watchers.TryGetValue(s, out fcw))
{
fcw.Enabled = false;
}
}
public void EnableWatcher(string FileName)
{
string s = FileName.ToLower();
FileChangeWatcher fcw = null;
if (watchers.TryGetValue(s, out fcw))
{
fcw.Enabled = true;
}
}
public void RemoveWatcher(string FileName)
{
try
{
string s = FileName.ToLower();
FileChangeWatcher fcw = null;
if (watchers.TryGetValue(s, out fcw))
{
fcw.Dispose();
watchers.Remove(s);
}
}
catch
{
}
}
}
}