예제 #1
0
        /// <summary>
        /// Notifies all subscriptions about the given change.
        /// </summary>
        /// <param name="changeType"></param>
        /// <param name="path"></param>
        private void RaiseSingleEvent(string path, FileWatchChangeType changeType)
        {
            var report = new Queue <FileWatchEvent>(1);

            report.Enqueue(new FileWatchEvent(changeType, path));
            RaiseEvents(report);
        }
예제 #2
0
        protected static MediaSourceChangeType TranslateChangeType(FileWatchChangeType changeType)
        {
            switch (changeType)
            {
            case FileWatchChangeType.Created:
                return(MediaSourceChangeType.Created);

            case FileWatchChangeType.Deleted:
                return(MediaSourceChangeType.Deleted);

            case FileWatchChangeType.Changed:
                return(MediaSourceChangeType.Changed);

            case FileWatchChangeType.Renamed:
                return(MediaSourceChangeType.Renamed);

            case FileWatchChangeType.All:
                return(MediaSourceChangeType.All);

            case FileWatchChangeType.DirectoryDeleted:
                return(MediaSourceChangeType.DirectoryDeleted);

            default:
                return(MediaSourceChangeType.None);
            }
        }
예제 #3
0
 /// <summary>
 /// Initializes a new instance of the FileWatchEvent class.
 /// </summary>
 /// <param name="type">Type of event.</param>
 /// <param name="path">Affected path.</param>
 /// <param name="oldPath">The old path to the affected path.</param>
 public FileWatchEvent(FileWatchChangeType type, string path, string oldPath)
 {
     _eventMoment = DateTime.Now;
     _path        = path;
     _oldPath     = oldPath;
     _type        = type;
     _fileSize    = GetFileSize(_path);
 }
예제 #4
0
 /// <summary>
 /// Initializes a new instance of the FileWatchEvent class.
 /// Rename events are not allowed with this constructor.
 /// </summary>
 /// <param name="type">Type of event.</param>
 /// <param name="path">Affected path.</param>
 public FileWatchEvent(FileWatchChangeType type, string path)
 {
     _eventMoment = DateTime.Now;
     if (type == FileWatchChangeType.Renamed)
     {
         throw new ArgumentException("The specified type indicates a Rename event. Rename events need the extra parameter \"oldPath\".");
     }
     _path     = path;
     _oldPath  = path;
     _type     = type;
     _fileSize = GetFileSize(_path);
 }
예제 #5
0
        /// <summary>
        /// Initializes a new instance of the FileWatchEvent class
        /// based on the specified FileSystemEventArgs.
        /// </summary>
        /// <param name="args">FileSystemEventArgs to base the current FileWatchEvent on.</param>
        public FileWatchEvent(FileSystemEventArgs args)
        {
            _eventMoment = DateTime.Now;
            _path        = args.FullPath;
            if (args is RenamedEventArgs)
            {
                _oldPath = ((RenamedEventArgs)args).OldFullPath;
            }
            else
            {
                _oldPath = _path;
            }
            switch (args.ChangeType)
            {
            case WatcherChangeTypes.All:
                _type = FileWatchChangeType.All;
                break;

            case WatcherChangeTypes.Changed:
                _type = FileWatchChangeType.Changed;
                break;

            case WatcherChangeTypes.Created:
                _type = FileWatchChangeType.Created;
                break;

            case WatcherChangeTypes.Deleted:
                _type = FileWatchChangeType.Deleted;
                break;

            case WatcherChangeTypes.Renamed:
                _type = FileWatchChangeType.Renamed;
                break;
            }
            _fileSize = GetFileSize(_path);
        }
 public FileWatchEventArgs(FileWatchChangeType changeType, string path, string oldPath)
 {
     _path       = path;
     _oldPath    = oldPath;
     _changeType = changeType;
 }
 public FileWatchEventArgs(FileWatchChangeType changeType, string path)
     : this(changeType, path, path)
 {
 }
 /// <summary>
 /// Returns whether events may be raised for the given <see cref="FileWatchChangeType"/>.
 /// </summary>
 /// <param name="changeType"><see cref="FileWatchChangeType"/> to test.</param>
 /// <returns></returns>
 private bool CompliesToChangeType(FileWatchChangeType changeType)
 {
     return(_changeTypes.Count == 0 || (_changeTypes.Contains(changeType)));
 }
예제 #9
0
 /// <summary>
 /// Notifies all subscriptions about the given change.
 /// </summary>
 /// <param name="changeType"></param>
 /// <param name="path"></param>
 private void RaiseSingleEvent(string path, FileWatchChangeType changeType)
 {
   var report = new Queue<FileWatchEvent>(1);
   report.Enqueue(new FileWatchEvent(changeType, path));
   RaiseEvents(report);
 }
예제 #10
0
 public FileWatchEventArgs(FileWatchChangeType changeType, string path, string oldPath)
 {
   _path = path;
   _oldPath = oldPath;
   _changeType = changeType;
 }
예제 #11
0
 /// <summary>
 /// Returns whether events may be raised for the given <see cref="FileWatchChangeType"/>.
 /// </summary>
 /// <param name="changeType"><see cref="FileWatchChangeType"/> to test.</param>
 /// <returns></returns>
 private bool CompliesToChangeType(FileWatchChangeType changeType)
 {
   return _changeTypes.Count == 0 || (_changeTypes.Contains(changeType));
 }
예제 #12
0
 public FileWatchEventArgs(FileWatchChangeType changeType, string path)
   : this(changeType, path, path)
 {
 }
예제 #13
0
 /// <summary>
 /// Initializes a new instance of the FileWatchEvent class.
 /// </summary>
 /// <param name="type">Type of event.</param>
 /// <param name="path">Affected path.</param>
 /// <param name="oldPath">The old path to the affected path.</param>
 public FileWatchEvent(FileWatchChangeType type, string path, string oldPath)
 {
   _eventMoment = DateTime.Now;
   _path = path;
   _oldPath = oldPath;
   _type = type;
   _fileSize = GetFileSize(_path);
 }
예제 #14
0
 /// <summary>
 /// Initializes a new instance of the FileWatchEvent class.
 /// Rename events are not allowed with this constructor.
 /// </summary>
 /// <param name="type">Type of event.</param>
 /// <param name="path">Affected path.</param>
 public FileWatchEvent(FileWatchChangeType type, string path)
 {
   _eventMoment = DateTime.Now;
   if (type == FileWatchChangeType.Renamed)
     throw new ArgumentException("The specified type indicates a Rename event. Rename events need the extra parameter \"oldPath\".");
   _path = path;
   _oldPath = path;
   _type = type;
   _fileSize = GetFileSize(_path);
 }
예제 #15
0
 /// <summary>
 /// Initializes a new instance of the FileWatchEvent class
 /// based on the specified FileSystemEventArgs.
 /// </summary>
 /// <param name="args">FileSystemEventArgs to base the current FileWatchEvent on.</param>
 public FileWatchEvent(FileSystemEventArgs args)
 {
   _eventMoment = DateTime.Now;
   _path = args.FullPath;
   if (args is RenamedEventArgs)
     _oldPath = ((RenamedEventArgs)args).OldFullPath;
   else
     _oldPath = _path;
   switch (args.ChangeType)
   {
     case WatcherChangeTypes.All:
       _type = FileWatchChangeType.All;
       break;
     case WatcherChangeTypes.Changed:
       _type = FileWatchChangeType.Changed;
       break;
     case WatcherChangeTypes.Created:
       _type = FileWatchChangeType.Created;
       break;
     case WatcherChangeTypes.Deleted:
       _type = FileWatchChangeType.Deleted;
       break;
     case WatcherChangeTypes.Renamed:
       _type = FileWatchChangeType.Renamed;
       break;
   }
   _fileSize = GetFileSize(_path);
 }
 protected static MediaSourceChangeType TranslateChangeType(FileWatchChangeType changeType)
 {
   switch (changeType)
   {
     case FileWatchChangeType.Created:
       return MediaSourceChangeType.Created;
     case FileWatchChangeType.Deleted:
       return MediaSourceChangeType.Deleted;
     case FileWatchChangeType.Changed:
       return MediaSourceChangeType.Changed;
     case FileWatchChangeType.Renamed:
       return MediaSourceChangeType.Renamed;
     case FileWatchChangeType.All:
       return MediaSourceChangeType.All;
     case FileWatchChangeType.DirectoryDeleted:
       return MediaSourceChangeType.DirectoryDeleted;
     default:
       return MediaSourceChangeType.None;
   }
 }