Ejemplo n.º 1
0
 public Project?FindPertinentProject(RelPath path)
 {
     return(IsLocalMatch(path)
         ? this
         : References
            .Select(x => x.FindPertinentProject(path))
            .FirstOrDefault());
 }
Ejemplo n.º 2
0
        public bool IsChildPathOf(RelPath parent)
        {
            if (parent.Segments.Length > Segments.Length)
            {
                return(false);
            }

            return(parent.Segments
                   .Zip(
                       Segments.Take(parent.Segments.Length),
                       (left, right) => left.Equals(right))
                   .All(x => x));
        }
Ejemplo n.º 3
0
        private Project ParseProject(RelPath projectFilePath, RelPath root)
        {
            _logger.LogWarning("Parsing project at {path}", projectFilePath.Path);
            var projectFileXml = XElement.Parse(_filesystem.ReadFile(projectFilePath.Path));

            var projectFolder = projectFilePath.Parent;

            var otherProjects = projectFileXml
                                .Descendants("ProjectReference")
                                .Select(x => x.Attribute("Include").Value)
                                .Select(x => RelPath.FromString(x).RelativeTo(projectFolder).RelativeTo(root))
                                .Select(x => ParseProject(x, root))
                                .ToArray();

            return(new Project(projectFilePath, otherProjects));
        }
        public IObservable <RelPath> WatchFolder(RelPath folder)
        {
            var absPath   = io.Path.GetFullPath(folder.Path);
            var binFolder = io.Path.Combine(absPath, "bin");
            var objFolder = io.Path.Combine(absPath, "bin");

            var relativeRoot = absPath;

            foreach (var segment in folder.Segments)
            {
                relativeRoot = io.Directory.GetParent(relativeRoot).FullName;
            }

            _logger.LogDebug("Starting filesystem watcher at {path}; relative path: {folder}; relative root: {relativeRoot}", absPath, folder, relativeRoot);
            var baseObservable = Observable.Create <string>(observer => {
                var watcher = new io.FileSystemWatcher(absPath)
                {
                    IncludeSubdirectories = true
                };

                watcher.Changed += (o, e) => observer.OnNext(e.FullPath);
                watcher.Created += (o, e) => observer.OnNext(e.FullPath);
                watcher.Deleted += (o, e) => observer.OnNext(e.FullPath);
                watcher.Renamed += (o, e) => observer.OnNext(e.FullPath);

                watcher.EnableRaisingEvents = true;

                return(watcher);
            })
                                 .Where(x => !x.StartsWith(binFolder))
                                 .Where(x => !x.StartsWith(objFolder))
                                 .Select(x => io.Path.GetRelativePath(relativeRoot, x))
                                 .Select(RelPath.FromString);

            return(baseObservable
                   .Select(x => {
                _logger.LogDebug("Got change for path {changedPath}", x);

                return x;
            }));
        }
Ejemplo n.º 5
0
 public Project Load(RelPath projectFilePath)
 {
     return(ParseProject(projectFilePath, RelPath.FromString("")));
 }
Ejemplo n.º 6
0
 public Project(RelPath csProjPath, params Project[] references)
 {
     CsProjPath = csProjPath;
     References = references;
 }
Ejemplo n.º 7
0
 private bool IsLocalMatch(RelPath path) =>
 path.IsSameAs(CsProjPath) || (
     path.IsChildPathOf(ProjectFolder) &&
     path.Segments.Last().EndsWith(".cs")
     );
Ejemplo n.º 8
0
 public bool IsMatch(RelPath path) =>
 FindPertinentProject(path) != null;
Ejemplo n.º 9
0
 public bool IsSameAs(RelPath other)
 {
     return(JoinSegments(Segments).Equals(JoinSegments(other.Segments)));
 }
Ejemplo n.º 10
0
        public RelPath Append(RelPath childPath)
        {
            var segments = CollapseRelPaths(Segments, childPath.Segments);

            return(new RelPath(segments));
        }
Ejemplo n.º 11
0
        public RelPath RelativeTo(RelPath startPoint)
        {
            var segments = CollapseRelPaths(startPoint.Segments, Segments);

            return(new RelPath(segments));
        }