-
Notifications
You must be signed in to change notification settings - Fork 264
Expand file tree
/
Copy pathFileSystemWatcherBase.cs
More file actions
146 lines (116 loc) · 4.93 KB
/
FileSystemWatcherBase.cs
File metadata and controls
146 lines (116 loc) · 4.93 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
using System.ComponentModel;
namespace System.IO.Abstractions
{
/// <inheritdoc cref="FileSystemWatcher"/>
#if FEATURE_SERIALIZABLE
[Serializable]
#endif
public abstract class FileSystemWatcherBase : IFileSystemWatcher
{
/// <inheritdoc />
public abstract IFileSystem FileSystem { get; }
/// <inheritdoc cref="FileSystemWatcher.IncludeSubdirectories"/>
public abstract bool IncludeSubdirectories { get; set; }
/// <inheritdoc cref="ComponentModel.Container"/>
public abstract IContainer Container { get; }
/// <inheritdoc cref="FileSystemWatcher.EnableRaisingEvents"/>
public abstract bool EnableRaisingEvents { get; set; }
/// <inheritdoc cref="FileSystemWatcher.Filter"/>
public abstract string Filter { get; set; }
#if FEATURE_FILE_SYSTEM_WATCHER_FILTERS
/// <inheritdoc cref="FileSystemWatcher.Filters"/>
public abstract Collections.ObjectModel.Collection<string> Filters { get; }
#endif
/// <inheritdoc cref="FileSystemWatcher.InternalBufferSize"/>
public abstract int InternalBufferSize { get; set; }
/// <inheritdoc cref="FileSystemWatcher.NotifyFilter"/>
public abstract NotifyFilters NotifyFilter { get; set; }
/// <inheritdoc cref="FileSystemWatcher.Path"/>
public abstract string Path { get; set; }
/// <inheritdoc cref="FileSystemWatcher.Site"/>
public abstract ISite Site { get; set; }
/// <inheritdoc cref="FileSystemWatcher.SynchronizingObject"/>
public abstract ISynchronizeInvoke SynchronizingObject { get; set; }
/// <inheritdoc cref="FileSystemWatcher.Changed"/>
public virtual event FileSystemEventHandler Changed;
/// <inheritdoc cref="FileSystemWatcher.Created"/>
public virtual event FileSystemEventHandler Created;
/// <inheritdoc cref="FileSystemWatcher.Deleted"/>
public virtual event FileSystemEventHandler Deleted;
/// <inheritdoc cref="FileSystemWatcher.Error"/>
public virtual event ErrorEventHandler Error;
/// <inheritdoc cref="FileSystemWatcher.Renamed"/>
public virtual event RenamedEventHandler Renamed;
/// <inheritdoc cref="FileSystemWatcher.BeginInit"/>
public abstract void BeginInit();
/// <inheritdoc />
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
/// <inheritdoc cref="FileSystemWatcher.EndInit"/>
public abstract void EndInit();
/// <inheritdoc cref="FileSystemWatcher.WaitForChanged(WatcherChangeTypes)"/>
public abstract IWaitForChangedResult WaitForChanged(WatcherChangeTypes changeType);
/// <inheritdoc cref="FileSystemWatcher.WaitForChanged(WatcherChangeTypes,int)"/>
public abstract IWaitForChangedResult WaitForChanged(WatcherChangeTypes changeType, int timeout);
#if FEATURE_FILE_SYSTEM_WATCHER_WAIT_WITH_TIMESPAN
/// <inheritdoc cref="FileSystemWatcher.WaitForChanged(WatcherChangeTypes,TimeSpan)"/>
public abstract IWaitForChangedResult WaitForChanged(WatcherChangeTypes changeType, TimeSpan timeout);
#endif
/// <summary>
/// Implicitly converts a <see cref="FileSystemWatcher"/> to a <see cref="FileSystemWatcherBase"/>.
/// </summary>
public static implicit operator FileSystemWatcherBase(FileSystemWatcher watcher)
{
if (watcher == null)
{
return null;
}
return new FileSystemWatcherWrapper(new FileSystem(), watcher);
}
/// <summary>
/// Callback executed during <see cref="IDisposable.Dispose()"/>
/// </summary>
public virtual void Dispose(bool disposing)
{
// do nothing
}
/// <summary>
/// Invokes the <see cref="Created"/> event.
/// </summary>
protected void OnCreated(object sender, FileSystemEventArgs args)
{
Created?.Invoke(sender, args);
}
/// <summary>
/// Invokes the <see cref="Changed"/> event.
/// </summary>
protected void OnChanged(object sender, FileSystemEventArgs args)
{
Changed?.Invoke(sender, args);
}
/// <summary>
/// Invokes the <see cref="Deleted"/> event.
/// </summary>
protected void OnDeleted(object sender, FileSystemEventArgs args)
{
Deleted?.Invoke(sender, args);
}
/// <summary>
/// Invokes the <see cref="Renamed"/> event.
/// </summary>
protected void OnRenamed(object sender, RenamedEventArgs args)
{
Renamed?.Invoke(sender, args);
}
/// <summary>
/// Invokes the <see cref="Error"/> event.
/// </summary>
protected void OnError(object sender, ErrorEventArgs args)
{
Error?.Invoke(sender, args);
}
}
}