Skip to content

Commit 1375888

Browse files
author
Jens Weiermann
committed
added IFileSystemWatcher
1 parent 9d716b7 commit 1375888

6 files changed

Lines changed: 30 additions & 9 deletions

File tree

System.IO.Abstractions.TestingHelpers.Tests/MockFileSystemTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -352,8 +352,8 @@ public void MockFileSystem_FileSystemWatcher_ShouldBeAssignable()
352352

353353
private class TestFileSystemWatcherFactory : IFileSystemWatcherFactory
354354
{
355-
public FileSystemWatcherBase CreateNew() => new TestFileSystemWatcher(null);
356-
public FileSystemWatcherBase FromPath(string path) => new TestFileSystemWatcher(path);
355+
public IFileSystemWatcher CreateNew() => new TestFileSystemWatcher(null);
356+
public IFileSystemWatcher FromPath(string path) => new TestFileSystemWatcher(path);
357357
}
358358

359359
private class TestFileSystemWatcher : FileSystemWatcherBase

System.IO.Abstractions.TestingHelpers/MockFileSystemWatcherFactory.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
[Serializable]
44
public class MockFileSystemWatcherFactory : IFileSystemWatcherFactory
55
{
6-
public FileSystemWatcherBase CreateNew() =>
6+
public IFileSystemWatcher CreateNew() =>
77
throw new NotImplementedException(StringResources.Manager.GetString("FILE_SYSTEM_WATCHER_NOT_IMPLEMENTED_EXCEPTION"));
88

9-
public FileSystemWatcherBase FromPath(string path) =>
9+
public IFileSystemWatcher FromPath(string path) =>
1010
throw new NotImplementedException(StringResources.Manager.GetString("FILE_SYSTEM_WATCHER_NOT_IMPLEMENTED_EXCEPTION"));
1111
}
1212
}

System.IO.Abstractions/FileSystemWatcherBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ namespace System.IO.Abstractions
44
{
55
/// <inheritdoc cref="FileSystemWatcher"/>
66
[Serializable]
7-
public abstract class FileSystemWatcherBase : IDisposable
7+
public abstract class FileSystemWatcherBase : IDisposable, IFileSystemWatcher
88
{
99
/// <inheritdoc cref="FileSystemWatcher.IncludeSubdirectories"/>
1010
public abstract bool IncludeSubdirectories { get; set; }

System.IO.Abstractions/FileSystemWatcherFactory.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ namespace System.IO.Abstractions
88
[Serializable]
99
public class FileSystemWatcherFactory : IFileSystemWatcherFactory
1010
{
11-
public FileSystemWatcherBase CreateNew()
11+
public IFileSystemWatcher CreateNew()
1212
{
1313
return new FileSystemWatcherWrapper();
1414
}
1515

16-
public FileSystemWatcherBase FromPath(string path)
16+
public IFileSystemWatcher FromPath(string path)
1717
{
1818
return new FileSystemWatcherWrapper(path);
1919
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
namespace System.IO.Abstractions
2+
{
3+
public interface IFileSystemWatcher
4+
{
5+
bool EnableRaisingEvents { get; set; }
6+
string Filter { get; set; }
7+
bool IncludeSubdirectories { get; set; }
8+
int InternalBufferSize { get; set; }
9+
NotifyFilters NotifyFilter { get; set; }
10+
string Path { get; set; }
11+
12+
event FileSystemEventHandler Changed;
13+
event FileSystemEventHandler Created;
14+
event FileSystemEventHandler Deleted;
15+
event ErrorEventHandler Error;
16+
event RenamedEventHandler Renamed;
17+
18+
WaitForChangedResult WaitForChanged(WatcherChangeTypes changeType);
19+
WaitForChangedResult WaitForChanged(WatcherChangeTypes changeType, int timeout);
20+
}
21+
}

System.IO.Abstractions/IFileSystemWatcherFactory.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ public interface IFileSystemWatcherFactory
1111
/// Initializes a new instance of the <see cref="FileSystemWatcherBase"/> class, which acts as a wrapper for a FileSystemWatcher
1212
/// </summary>
1313
/// <returns></returns>
14-
FileSystemWatcherBase CreateNew();
14+
IFileSystemWatcher CreateNew();
1515

1616
/// <summary>
1717
/// Initializes a new instance of the <see cref="FileSystemWatcherBase"/> class, which acts as a wrapper for a FileSystemWatcher
1818
/// </summary>
1919
/// <param name="path">Path to generate the FileSystemWatcherBase for</param>
2020
/// <returns></returns>
21-
FileSystemWatcherBase FromPath(string path);
21+
IFileSystemWatcher FromPath(string path);
2222
}
2323
}

0 commit comments

Comments
 (0)