示例#1
0
 public PathChangeEntry(FullPath basePath, RelativePath entryPath, PathChangeKind changeKind, PathKind pathKind)
 {
     _basePath   = basePath;
     _entryPath  = entryPath;
     _changeKind = changeKind;
     _pathKind   = pathKind;
 }
    private static void LogPath(string path, PathChangeKind kind) {
#if false
      var pathToLog = @"";
      if (SystemPathComparer.Instance.IndexOf(path, pathToLog, 0, path.Length) == 0) {
        Logger.LogInfo("*************************** {0}: {1} *******************", path, kind);
      }
#endif
    }
        private static void LogPath(string path, PathChangeKind kind)
        {
#if false
            var pathToLog = @"";
            if (SystemPathComparer.Instance.IndexOf(path, pathToLog, 0, path.Length) == 0)
            {
                Logger.LogInfo("*************************** {0}: {1} *******************", path, kind);
            }
#endif
        }
        private void EnqueueChangeEvent(FullPath path, PathChangeKind changeKind)
        {
            //Logger.LogInfo("Enqueue change event: {0}, {1}", path, changeKind);
            LogLastChange(new ChangeLog {
                Entry        = new PathChangeEntry(path, changeKind),
                TimeStampUtc = _dateTimeProvider.UtcNow,
            });

            lock (_changedPathsLock) {
                MergePathChange(_changedPaths, path, changeKind);
            }
        }
示例#5
0
        private void EnqueueChangeEvent(FullPath rootPath, RelativePath entryPath, PathChangeKind changeKind, PathKind pathKind)
        {
            //Logger.LogInfo("Enqueue change event: {0}, {1}", path, changeKind);
            var entry = new PathChangeEntry(rootPath, entryPath, changeKind, pathKind);

            _globalChangeRecorder.RecordChange(new PathChangeRecorder.ChangeInfo {
                Entry        = entry,
                TimeStampUtc = _dateTimeProvider.UtcNow,
            });

            lock (_changedPathsLock) {
                MergePathChange(_changedPaths, entry);
            }
        }
 private static PathChangeKind CombineChangeKinds(PathChangeKind current, PathChangeKind next)
 {
     switch (current) {
     case PathChangeKind.None:
       return next;
     case PathChangeKind.Created:
       switch (next) {
     case PathChangeKind.None:
       return current;
     case PathChangeKind.Created:
       return current;
     case PathChangeKind.Deleted:
       return PathChangeKind.None;
     case PathChangeKind.Changed:
       return current;
     default:
       throw new ArgumentOutOfRangeException("next");
       }
     case PathChangeKind.Deleted:
       switch (next) {
     case PathChangeKind.None:
       return current;
     case PathChangeKind.Created:
       return PathChangeKind.Changed;
     case PathChangeKind.Deleted:
       return current;
     case PathChangeKind.Changed:
       return PathChangeKind.Deleted; // Weird case...
     default:
       throw new ArgumentOutOfRangeException("next");
       }
     case PathChangeKind.Changed:
       switch (next) {
     case PathChangeKind.None:
       return current;
     case PathChangeKind.Created:
       return PathChangeKind.Changed; // Weird case...
     case PathChangeKind.Deleted:
       return next;
     case PathChangeKind.Changed:
       return current;
     default:
       throw new ArgumentOutOfRangeException("next");
       }
     default:
       throw new ArgumentOutOfRangeException("current");
       }
 }
        private bool IncludeChange(FullPath path, PathChangeKind changeKind)
        {
            // Ignore changes for files that have been created then deleted
            if (changeKind == PathChangeKind.None)
            {
                return(false);
            }

            // Changes to a directory entry are irrelevant (we will get notifications
            // for files inside the directory is anything relevant occured.)
            if (_fileSystem.DirectoryExists(path))
            {
                if (changeKind == PathChangeKind.Changed)
                {
                    return(false);
                }
            }

            return(true);
        }
 private void EnqueueChangeEvent(FullPathName path, PathChangeKind changeKind)
 {
     lock (_changedPathsLock) {
         MergePathChange(_changedPaths, path, changeKind);
     }
 }
 public PathChangeEntry(FullPathName path, PathChangeKind kind)
 {
     _path = path;
       _kind = kind;
 }
    private void EnqueueChangeEvent(FullPath path, PathChangeKind changeKind) {
      //Logger.LogInfo("Enqueue change event: {0}, {1}", path, changeKind);
      LogLastChange(new ChangeLog {
        Entry = new PathChangeEntry(path, changeKind),
        TimeStampUtc = _dateTimeProvider.UtcNow,
      });

      lock (_changedPathsLock) {
        MergePathChange(_changedPaths, path, changeKind);
      }
    }
 private void EnqueueChangeEvent(FullPath path, PathChangeKind changeKind)
 {
     lock (_changedPathsLock) {
     MergePathChange(_changedPaths, path, changeKind);
       }
 }
 private static void MergePathChange(Dictionary<FullPath, PathChangeKind> changes, FullPath path, PathChangeKind kind)
 {
     PathChangeKind currentChangeKind;
       if (!changes.TryGetValue(path, out currentChangeKind)) {
     currentChangeKind = PathChangeKind.None;
       }
       changes[path] = CombineChangeKinds(currentChangeKind, kind);
 }
示例#13
0
            private State OnWatcherSingleFileChange(object sender, FileSystemEventArgs args, PathKind pathKind, PathChangeKind changeKind)
            {
                var watcher = (IFileSystemWatcher)sender;

                var path = PathHelpers.CombinePaths(watcher.Path.Value, args.Name);

                LogPathForDebugging(path, PathChangeKind.Changed, pathKind);
                if (SkipPath(path))
                {
                    return(this);
                }

                EnqueueChangeEvent(watcher.Path, new RelativePath(args.Name), changeKind, pathKind);
                StateHost.PollingThread.WakeUp();
                return(this);
            }
        private static void MergePathChange(Dictionary <FullPathName, PathChangeKind> changes, FullPathName path, PathChangeKind kind)
        {
            PathChangeKind currentChangeKind;

            if (!changes.TryGetValue(path, out currentChangeKind))
            {
                currentChangeKind = PathChangeKind.None;
            }
            changes[path] = CombineChangeKinds(currentChangeKind, kind);
        }
示例#15
0
 public PathChangeEntry(FullPathName path, PathChangeKind kind)
 {
     _path = path;
     _kind = kind;
 }
        private static PathChangeKind CombineChangeKinds(PathChangeKind current, PathChangeKind next)
        {
            switch (current)
            {
            case PathChangeKind.None:
                return(next);

            case PathChangeKind.Created:
                switch (next)
                {
                case PathChangeKind.None:
                    return(current);

                case PathChangeKind.Created:
                    return(current);

                case PathChangeKind.Deleted:
                    return(PathChangeKind.None);

                case PathChangeKind.Changed:
                    return(current);

                default:
                    throw new ArgumentOutOfRangeException("next");
                }

            case PathChangeKind.Deleted:
                switch (next)
                {
                case PathChangeKind.None:
                    return(current);

                case PathChangeKind.Created:
                    return(PathChangeKind.Changed);

                case PathChangeKind.Deleted:
                    return(current);

                case PathChangeKind.Changed:
                    return(PathChangeKind.Deleted); // Weird case...

                default:
                    throw new ArgumentOutOfRangeException("next");
                }

            case PathChangeKind.Changed:
                switch (next)
                {
                case PathChangeKind.None:
                    return(current);

                case PathChangeKind.Created:
                    return(PathChangeKind.Changed); // Weird case...

                case PathChangeKind.Deleted:
                    return(next);

                case PathChangeKind.Changed:
                    return(current);

                default:
                    throw new ArgumentOutOfRangeException("next");
                }

            default:
                throw new ArgumentOutOfRangeException("current");
            }
        }
    private bool IncludeChange(FullPath path, PathChangeKind changeKind) {
      // Ignore changes for files that have been created then deleted
      if (changeKind == PathChangeKind.None)
        return false;

      // Changes to a directory entry are irrelevant (we will get notifications
      // for files inside the directory is anything relevant occured.)
      if (_fileSystem.DirectoryExists(path)) {
        if (changeKind == PathChangeKind.Changed)
          return false;
      }

      return true;
    }