Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: tathamoddie/System.IO.Abstractions
base: 5373737dce
...
head fork: tathamoddie/System.IO.Abstractions
compare: 7aed17bb1e
Checking mergeability… Don't worry, you can still create the pull request.
  • 2 commits
  • 3 files changed
  • 0 commit comments
  • 2 contributors
Commits on Feb 21, 2014
@KallDrexx KallDrexx Added base and wrapper for the FileSystemWatcher class
Removed jmconfig file (no idea where that came from)

Updated Base and wrapper classes to properly deal with the events and bubble up the concrete FileSystemWatcher events up to the wrapper class.
0dc8f36
@tathamoddie Merge pull request #59 from KallDrexx/FileSystemWatcher-Abstraction
Added base and wrapper for the FileSystemWatcher class
7aed17b
View
65 System.IO.Abstractions/FileSystemWatcherBase.cs
@@ -0,0 +1,65 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Linq;
+using System.Text;
+
+namespace System.IO.Abstractions
+{
+ [Serializable]
+ public abstract class FileSystemWatcherBase : IDisposable
+ {
+ public abstract bool EnableRaisingEvents { get; set; }
+ public abstract string Filter { get; set; }
+ public abstract int InternalBufferSize { get; set; }
+ public abstract NotifyFilters NotifyFilter { get; set; }
+ public abstract string Path { get; set; }
+ public abstract ISite Site { get; set; }
+ public abstract ISynchronizeInvoke SynchronizingObject { get; set; }
+ public event FileSystemEventHandler Changed;
+ public event FileSystemEventHandler Created;
+ public event FileSystemEventHandler Deleted;
+ public event ErrorEventHandler Error;
+ public event RenamedEventHandler Renamed;
+ public abstract void BeginInit();
+ public abstract void Dispose();
+ public abstract void EndInit();
+ public abstract WaitForChangedResult WaitForChanged(WatcherChangeTypes changeType);
+ public abstract WaitForChangedResult WaitForChanged(WatcherChangeTypes changeType, int timeout);
+
+ public static implicit operator FileSystemWatcherBase(FileSystemWatcher watcher)
+ {
+ return new FileSystemWatcherWrapper(watcher);
+ }
+
+ protected void OnCreated(object sender, FileSystemEventArgs args)
+ {
+ if (Created != null)
+ Created(sender, args);
+ }
+
+ protected void OnChanged(object sender, FileSystemEventArgs args)
+ {
+ if (Changed != null)
+ Changed(sender, args);
+ }
+
+ protected void OnDeleted(object sender, FileSystemEventArgs args)
+ {
+ if (Deleted != null)
+ Deleted(sender, args);
+ }
+
+ protected void OnRenamed(object sender, RenamedEventArgs args)
+ {
+ if (Renamed != null)
+ Renamed(sender, args);
+ }
+
+ protected void OnError(object sender, ErrorEventArgs args)
+ {
+ if (Error != null)
+ Error(sender, args);
+ }
+ }
+}
View
113 System.IO.Abstractions/FileSystemWatcherWrapper.cs
@@ -0,0 +1,113 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Linq;
+using System.Text;
+
+namespace System.IO.Abstractions
+{
+ [Serializable]
+ public class FileSystemWatcherWrapper : FileSystemWatcherBase
+ {
+ private readonly FileSystemWatcher watcher;
+
+ public FileSystemWatcherWrapper()
+ {
+ watcher = new FileSystemWatcher();
+ SetupEvents();
+ }
+
+ public FileSystemWatcherWrapper(string path)
+ {
+ watcher = new FileSystemWatcher(path);
+ SetupEvents();
+ }
+
+ public FileSystemWatcherWrapper(string path, string filter)
+ {
+ watcher = new FileSystemWatcher(path, filter);
+ SetupEvents();
+ }
+
+ public FileSystemWatcherWrapper(FileSystemWatcher watcher)
+ {
+ this.watcher = watcher;
+ }
+
+ public override bool EnableRaisingEvents
+ {
+ get { return watcher.EnableRaisingEvents; }
+ set { watcher.EnableRaisingEvents = value; }
+ }
+
+ public override string Filter
+ {
+ get { return watcher.Filter; }
+ set { watcher.Filter = value; }
+ }
+
+ public override int InternalBufferSize
+ {
+ get { return watcher.InternalBufferSize; }
+ set { watcher.InternalBufferSize = value; }
+ }
+
+ public override NotifyFilters NotifyFilter
+ {
+ get { return watcher.NotifyFilter; }
+ set { watcher.NotifyFilter = value; }
+ }
+
+ public override string Path
+ {
+ get { return watcher.Path; }
+ set { watcher.Path = value; }
+ }
+
+ public override ISite Site
+ {
+ get { return watcher.Site; }
+ set { watcher.Site = value; }
+ }
+
+ public override ISynchronizeInvoke SynchronizingObject
+ {
+ get { return watcher.SynchronizingObject; }
+ set { watcher.SynchronizingObject = value; }
+ }
+
+ public override void BeginInit()
+ {
+ watcher.BeginInit();
+ }
+
+ public override void Dispose()
+ {
+ watcher.Dispose();
+ }
+
+ public override void EndInit()
+ {
+ watcher.EndInit();
+ }
+
+ public override WaitForChangedResult WaitForChanged(WatcherChangeTypes changeType)
+ {
+ return watcher.WaitForChanged(changeType);
+ }
+
+ public override WaitForChangedResult WaitForChanged(WatcherChangeTypes changeType, int timeout)
+ {
+ return watcher.WaitForChanged(changeType, timeout);
+ }
+
+ private void SetupEvents()
+ {
+ watcher.Created += OnCreated;
+ watcher.Changed += OnChanged;
+ watcher.Deleted += OnDeleted;
+ watcher.Error += OnError;
+ watcher.Renamed += OnRenamed;
+ }
+ }
+}
View
2  System.IO.Abstractions/System.IO.Abstractions.csproj
@@ -76,6 +76,8 @@
<Compile Include="FileInfoWrapper.cs" />
<Compile Include="FileSystem.cs" />
<Compile Include="FileSystemInfoBase.cs" />
+ <Compile Include="FileSystemWatcherBase.cs" />
+ <Compile Include="FileSystemWatcherWrapper.cs" />
<Compile Include="FileWrapper.cs" />
<Compile Include="FileBase.cs" />
<Compile Include="IDirectoryInfoFactory.cs" />

No commit comments for this range

Something went wrong with that request. Please try again.