Пример #1
0
 private static bool MaybeDirectoryCreation(PathChangeEntry entry)
 {
     if (entry.ChangeKind == PathChangeKind.Created)
     {
         return(entry.PathKind == PathKind.Directory ||
                entry.PathKind == PathKind.FileOrDirectory ||
                entry.PathKind == PathKind.FileAndDirectory);
     }
     return(false);
 }
        private bool IncludeChange(PathChangeEntry change)
        {
            var path       = change.Path;
            var changeType = change.Kind;

            // Ignore changes for files that have been created then deleted
            if (changeType == PathChangeKind.None)
            {
                return(false);
            }

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

            return(true);
        }
        private bool PathIsExcluded(PathChangeEntry change)
        {
            var path    = change.Path;
            var project = _projectDiscovery.GetProject(path);

            if (project == null)
            {
                return(true);
            }

            // If path is root itself, it is never excluded.
            if (path == project.RootPath)
            {
                return(false);
            }

            // Split relative part into list of name components.
            var split        = PathHelpers.SplitPrefix(path.Value, project.RootPath.Value);
            var relativePath = split.Suffix;
            var names        = relativePath.Split(Path.DirectorySeparatorChar);

            // Check each relative path from root path to full path.
            var pathToItem = new RelativePath();

            foreach (var item in names)
            {
                var relativePathToItem = pathToItem.CreateChild(item);

                bool exclude;
                // For the last component, we might not if it is a file or directory.
                // Check depending on the change kind.
                if (item == names.Last())
                {
                    if (change.Kind == PathChangeKind.Deleted)
                    {
                        exclude = false;
                    }
                    else
                    {
                        var info = _fileSystem.GetFileInfoSnapshot(path);
                        if (info.IsFile)
                        {
                            exclude = !project.FileFilter.Include(relativePathToItem);
                        }
                        else if (info.IsDirectory)
                        {
                            exclude = !project.DirectoryFilter.Include(relativePathToItem);
                        }
                        else
                        {
                            // We don't know... Be conservative.
                            exclude = false;
                        }
                    }
                }
                else
                {
                    exclude = !project.DirectoryFilter.Include(relativePathToItem);
                }

                if (exclude)
                {
                    return(true);
                }

                pathToItem = relativePathToItem;
            }
            return(false);
        }
 private static bool IsProjectFileChange(PathChangeEntry change)
 {
     return
         (SystemPathComparer.Instance.StringComparer.Equals(change.Path.FileName, ConfigurationFileNames.ProjectFileNameObsolete) ||
          SystemPathComparer.Instance.StringComparer.Equals(change.Path.FileName, ConfigurationFileNames.ProjectFileName));
 }
        private bool IncludeChange(PathChangeEntry change)
        {
            var path = change.Path;
              var changeType = change.Kind;

              // Ignore changes for files that have been created then deleted
              if (changeType == PathChangeKind.None)
            return false;

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

              return true;
        }