Here are the examples of the csharp api ONI_Common.IO.FileChangeNotifier.InitializeWatcher(System.IO.FileSystemWatcher) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
1 Examples
19
Source : FileChangeNotifier.cs
with MIT License
from javisar
with MIT License
from javisar
public static void StartFileWatch(string filter, string parentDirectory, FileSystemEventHandler callback)
{
FileWatcherInfo watcherInfo = null;
foreach (FileWatcherInfo info in _fileWatcherInfos)
{
FileSystemWatcher watcher = info.FileWatcher;
if (watcher.Filter != filter || watcher.Path != parentDirectory)
{
continue;
}
watcherInfo = info; // TODO REFACTOR (weakman) This replacedigned value is never used....
return; // ...because of this return,
}
if (watcherInfo == null)
{
// REFACTOR (weakman) , Which means this is currently always true...
IOHelper.EnsureDirectoryExists(parentDirectory);
watcherInfo = new FileWatcherInfo(new FileSystemWatcher(parentDirectory, filter), callback);
InitializeWatcher(watcherInfo.FileWatcher);
_fileWatcherInfos.Add(watcherInfo);
}
else
{
// REFACTOR (weakman) ...so this is never executed
foreach (FileSystemEventHandler sub in watcherInfo.Subscribers)
{
if (sub == callback)
{
// already subscribed to this watcher
return;
}
}
watcherInfo.TryAddSubscriber(callback);
}
}