public static ProjectExplorer Load(string path) { string bprojPath = null; if (path.EndsWith(".bproj")) { bprojPath = path; path = new DirectoryInfo(path).Parent.FullName; } else { string[] rootFiles = Directory.GetFiles(path); for (int i = 0; i < rootFiles.Length; i++) { string rootFile = rootFiles[i]; if (rootFile.EndsWith(".bproj", StringComparison.Ordinal)) { bprojPath = rootFile; break; } } } var project = new ProjectExplorer { Definition = ProjectDefinitionFile.Load(bprojPath) }; string[] directories = Directory.GetDirectories(path); foreach (string folder in directories) { var directoryInfo = new DirectoryInfo(folder); var projectFolder = new ProjectAsset(directoryInfo); project.Assets.Add(projectFolder); } return(project); }
public static ProjectExplorer Load(string path) { string bprojPath = null; if (path.EndsWith(".bproj")) { bprojPath = path; path = new DirectoryInfo(path).Parent.FullName; } else { string[] rootFiles = Directory.GetFiles(path); for (int i = 0; i < rootFiles.Length; i++) { string rootFile = rootFiles[i]; if (rootFile.EndsWith(".bproj", StringComparison.Ordinal)) { bprojPath = rootFile; break; } } } var project = new ProjectExplorer { Definition = ProjectDefinitionFile.Load(bprojPath) }; var ignoredDirectories = new List <string> () { Path.Combine(path, "bin") }; string normalizedPath = path.Replace('\\', '/'); long totalSize = 0; foreach (string filePath in Directory.EnumerateFiles(path, "*", SearchOption.AllDirectories)) { if (ignoredDirectories.Any(p => filePath.StartsWith(p))) { continue; } var file = new FileInfo(filePath); if (file.Extension == ".bproj") { continue; } string packageKey = filePath .Replace('\\', '/') .Replace(normalizedPath + "/", ""); var resource = new ProjectResource(packageKey, file); project.Resources.Add(resource); totalSize += resource.UncompressedSize; } project.UncompressedSize = totalSize; return(project); }
public static ProjectExplorer Load(string projectPath, ImportPipeline importPipeline) { string bprojPath = null; if (projectPath.EndsWith(".bproj")) { bprojPath = projectPath; projectPath = new DirectoryInfo(projectPath).Parent.FullName; } else { foreach (string rootFile in Directory.EnumerateFiles(projectPath, "*.bproj")) { bprojPath = rootFile; break; } } var resources = new Dictionary <string, ProjectResource>(); var projectExplorer = new ProjectExplorer { ProjectPath = projectPath, Definition = ProjectDefinitionFile.Load(bprojPath), resources = new ProjectResourceCollection(resources) }; projectExplorer.rootDirectory = CreateDirectory( projectPath.Replace('\\', '/'), projectPath, "/", projectExplorer, importPipeline ); // Size Calculation long uncompressedSize = 0; foreach (var resource in projectExplorer.Resources) { uncompressedSize += resource.UncompressedSize; } projectExplorer.UncompressedSize = uncompressedSize; // Tag Indexing var tags = new Dictionary <string, IResourceCollection>(); foreach (var resource in projectExplorer.Resources) { foreach (string tag in resource.Tags) { if (!tags.TryGetValue(tag, out var taggedResourcesCollection)) { taggedResourcesCollection = new ProjectResourceCollection(); tags[tag] = taggedResourcesCollection; } var taggedResources = (ProjectResourceCollection)taggedResourcesCollection; taggedResources.Add(resource); } } projectExplorer.tags = new PackageTagsCollection(tags); return(projectExplorer); }