Inheritance: DirectoryEntry
示例#1
0
        public static Tuple <DirectoryEntry, ImmutableList <ProjectEntry> > Create(DirectoryInfo dir, string relativePath)
        {
            if (relativePath == "packages")
            {
                return(new Tuple <DirectoryEntry, ImmutableList <ProjectEntry> >(PackagesEntry.Create(dir), null));
            }

            if (relativePath != null && File.Exists(Path.Combine(dir.FullName, "project.json")))
            {
                return(ProjectEntry.Create(dir, relativePath));
            }

            var dirsAndProjects = from d in dir.EnumerateDirectories()
                                  where !d.IsHidden()
                                  orderby d.Name
                                  select Create(d, Path.Combine(relativePath, d.Name));

            var dirs     = ImmutableList.CreateBuilder <DirectoryEntry>();
            var projects = ImmutableList.CreateBuilder <ProjectEntry>();

            foreach (var dap in dirsAndProjects)
            {
                if (dap.Item2 != null)
                {
                    projects.AddRange(dap.Item2);
                }
                dirs.Add(dap.Item1);
            }

            var files = from f in dir.EnumerateFiles()
                        where !f.IsHidden()
                        orderby f.Name
                        select(Entry) FileEntry.Create(f, Path.Combine(relativePath, f.Name));

            return(new Tuple <DirectoryEntry, ImmutableList <ProjectEntry> >(
                       new DirectoryEntry(relativePath, false, dir,
                                          dirs.ToImmutable(), files.ToImmutableList()),
                       projects.ToImmutable()));
        }
示例#2
0
        public static new Tuple<DirectoryEntry, ImmutableList<ProjectEntry>> Create(DirectoryInfo dir, string relativePath)
        {
            var dirsAndProjects = from d in dir.EnumerateDirectories()
                                  where !d.IsHidden()
                                  && !d.Name.Equals("bin", StringComparison.OrdinalIgnoreCase)
                                  && !d.Name.Equals("obj", StringComparison.OrdinalIgnoreCase)
                                  orderby d.Name
                                  select Create(d, IOPath.Combine(relativePath, d.Name));

            var dirs = ImmutableList.CreateBuilder<DirectoryEntry>();
            foreach (var dap in dirsAndProjects)
            {
                // Discard sub-projects
                dirs.Add(dap.Item1);
            }

            var files = from f in dir.EnumerateFiles()
                        where !f.IsHidden()
                        orderby f.Name
                        select (Entry)FileEntry.Create(f, IOPath.Combine(relativePath, f.Name));

            var project = new ProjectEntry(relativePath, false, dir, dirs.ToImmutable(), files.ToImmutableList(),
                new ReferencesEntry(false, relativePath + ":references", ImmutableList.Create<ReferenceEntry>(), null),
                ImmutableList.Create<DiagnosticMessage>(), -1, ImmutableList.Create<string>(), ImmutableDictionary.Create<string, string>(), null);
            return new Tuple<DirectoryEntry, ImmutableList<ProjectEntry>>(
                project,
                ImmutableList.Create(project));
        }