コード例 #1
0
        public static ProjectExplorer Load(string path)
        {
            var    rootFiles = Directory.GetFiles(path);
            string bprojPath = null;

            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
            {
                bProj = BProjModel.Load(bprojPath)
            };

            var directories = Directory.GetDirectories(path);

            foreach (var folder in directories)
            {
                var directoryInfo = new DirectoryInfo(folder);
                var projectFolder = new ProjectAsset(directoryInfo);
                project.Assets.Add(projectFolder);
            }
            return(project);
        }
コード例 #2
0
        internal ProjectResourceDependency(ProjectExplorer projectExplorer, string key, Dictionary <string, string> metdadata)
        {
            this.projectExplorer = projectExplorer;
            this.metdadata       = metdadata;

            Key = key;
        }
コード例 #3
0
        public override void IncludeInBuild(string output)
        {
            var accessPath      = Path.Combine(File.Path, IncludePath);
            var projectExplorer = ProjectExplorer.Load(accessPath);

            projectExplorer.Export(Path.Combine(output));
        }
コード例 #4
0
        public ProjectBuildProcess(BuildPipeline pipeline, ProjectExplorer project, string outputFolder)
        {
            Pipeline     = pipeline;
            Project      = project;
            OutputFolder = outputFolder;

            PackageDefinition = new PackageDefinitionFile();
        }
コード例 #5
0
ファイル: ImportPipeline.cs プロジェクト: MengQidaNa/RPGCore
        public ProjectResource ImportResource(ProjectExplorer projectExplorer, FileInfo fileInfo, string projectKey)
        {
            var resourceImporter = new ProjectResourceImporter(projectExplorer, fileInfo, projectKey);

            foreach (var importer in ImportProcessors)
            {
                importer.ProcessImport(resourceImporter);
            }

            return(resourceImporter.Import());
        }
コード例 #6
0
ファイル: ImportPipeline.cs プロジェクト: xJayLee/RPGCore
        public ProjectResource ImportResource(ProjectExplorer projectExplorer, ProjectDirectory directory, IArchiveFile archiveEntry, string projectKey)
        {
            var resourceImporter = new ProjectResourceImporter(projectExplorer, directory, archiveEntry, projectKey);

            foreach (var importer in processors)
            {
                importer.ProcessImport(resourceImporter);
            }

            return(resourceImporter.Import());
        }
コード例 #7
0
ファイル: ProjectExplorer.cs プロジェクト: sishui/RPGCore
        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);
        }
コード例 #8
0
ファイル: ProjectExplorer.cs プロジェクト: zhaowumu/RPGCore
        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);
        }
コード例 #9
0
 internal ProjectResourceDependencies(ProjectExplorer projectExplorer)
 {
     this.projectExplorer = projectExplorer;
     dependencies         = new List <ProjectResourceDependency>();
 }
コード例 #10
0
ファイル: ProjectExplorer.cs プロジェクト: xJayLee/RPGCore
        public static async Task <ProjectExplorer> LoadAsync(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 archive = new FileSystemArchive(new DirectoryInfo(projectPath));

            var resources = new Dictionary <string, ProjectResource>();

            var rootDirectiory = new ProjectDirectory("", "", null);

            var projectExplorer = new ProjectExplorer
            {
                Archive       = archive,
                Definition    = ProjectDefinition.Load(bprojPath),
                Resources     = new ProjectResourceCollection(resources),
                RootDirectory = rootDirectiory
            };

            void ImportDirectory(IArchiveDirectory directory, ProjectDirectory projectDirectory)
            {
                foreach (var childDirectory in directory.Directories)
                {
                    ImportDirectory(childDirectory,
                                    new ProjectDirectory(childDirectory.Name, childDirectory.FullName, projectDirectory));
                }

                foreach (var file in directory.Files)
                {
                    if (file.FullName.StartsWith("bin/") ||
                        file.FullName.EndsWith(".bproj") ||
                        !importPipeline.IsResource(file))
                    {
                        continue;
                    }

                    var resource = importPipeline.ImportResource(projectExplorer, projectDirectory, file, file.FullName);

                    projectExplorer.Resources.Add(resource.FullName, resource);
                    projectDirectory.Resources.Add(resource.Name, resource);
                }
            }

            ImportDirectory(archive.RootDirectory, rootDirectiory);

            foreach (var resource in projectExplorer.Resources)
            {
                foreach (var dependency in resource.Dependencies)
                {
                    var dependencyResource = dependency.Resource;

                    if (dependencyResource == null)
                    {
                        Console.WriteLine($"ERROR: Unable to resolve dependency for \"{dependency.Key}\"");
                    }
                    else
                    {
                        dependencyResource.Dependants.dependencies.Add(new ProjectResourceDependency(projectExplorer, resource.FullName, dependency.metdadata));
                    }
                }
            }

            // 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.FullName, resource);
                }
            }

            projectExplorer.Tags = new PackageTagsCollection(tags);

            return(projectExplorer);
        }
コード例 #11
0
 public ProjectBuildProcess(BuildPipeline pipeline, ProjectExplorer project, string outputFolder)
 {
     Pipeline     = pipeline;
     Project      = project;
     OutputFolder = outputFolder;
 }
コード例 #12
0
        private static ProjectDirectory CreateDirectory(string normalisedRootPath, string directoryPath, string projectKey, ProjectExplorer projectExplorer, ImportPipeline importPipeline)
        {
            var newRootDirectory = new ProjectDirectory(projectKey);

            foreach (string filePath in Directory.EnumerateFiles(directoryPath, "*", SearchOption.TopDirectoryOnly))
            {
                var resourceFileInfo = new FileInfo(filePath);

                if (resourceFileInfo.Extension == ".bproj")
                {
                    continue;
                }

                string resourceProjectKey = filePath
                                            .Replace('\\', '/')
                                            .Replace(normalisedRootPath + "/", "");

                var resource = importPipeline.ImportResource(projectExplorer, resourceFileInfo, resourceProjectKey);

                projectExplorer.Resources.Add(resource);

                newRootDirectory.AddChildResource(resource);
            }

            foreach (string directoryFullName in Directory.EnumerateDirectories(directoryPath, "*", SearchOption.AllDirectories))
            {
                var directoryInformation = new DirectoryInfo(directoryFullName);

                if (directoryInformation.Name == "bin")
                {
                    continue;
                }

                string directoryProjectKey = directoryFullName
                                             .Replace('\\', '/')
                                             .Replace(normalisedRootPath + "/", "");

                var childDirectory = CreateDirectory(normalisedRootPath, directoryFullName, directoryProjectKey, projectExplorer, importPipeline);

                newRootDirectory.AddChildDirectory(childDirectory);
            }

            return(newRootDirectory);
        }
コード例 #13
0
        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);
        }
コード例 #14
0
ファイル: ProjectExplorer.cs プロジェクト: mengtest/RPGCore
        public static async Task <ProjectExplorer> LoadAsync(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 archive = new FileSystemArchive(new DirectoryInfo(projectPath));

            var resources = new Dictionary <string, ProjectResource>();

            var rootDirectiory = new ProjectDirectory("", "", null);

            ProjectDirectory ForPath(string path)
            {
                int currentIndex     = 0;
                var currentDirectory = rootDirectiory;

                while (true)
                {
                    int nextIndex = path.IndexOf('/', currentIndex);
                    if (nextIndex == -1)
                    {
                        break;
                    }
                    string segment = path.Substring(currentIndex, nextIndex - currentIndex);

                    bool found = false;
                    foreach (var directory in currentDirectory.Directories)
                    {
                        if (directory.Name == segment)
                        {
                            currentDirectory = directory;
                            found            = true;
                            break;
                        }
                    }
                    if (!found)
                    {
                        var newDirectory = new ProjectDirectory(segment, path, currentDirectory);
                        currentDirectory.Directories.Add(newDirectory);
                        currentDirectory = newDirectory;
                    }

                    currentIndex = nextIndex + 1;
                }

                return(currentDirectory);
            }

            var projectExplorer = new ProjectExplorer
            {
                Archive       = archive,
                Definition    = ProjectDefinition.Load(bprojPath),
                Resources     = new ProjectResourceCollection(resources),
                RootDirectory = rootDirectiory
            };

            // Resources
            foreach (var projectEntry in archive.Files)
            {
                if (projectEntry.FullName.StartsWith("bin/") ||
                    projectEntry.FullName.EndsWith(".bproj"))
                {
                    continue;
                }

                if (!importPipeline.IsResource(projectEntry))
                {
                    continue;
                }

                var forPath = ForPath(projectEntry.FullName);

                var resource = importPipeline.ImportResource(projectExplorer, forPath, projectEntry, projectEntry.FullName);

                projectExplorer.Resources.Add(resource.FullName, resource);
                forPath.Resources.Add(resource.Name, resource);
            }

            foreach (var resource in projectExplorer.Resources)
            {
                foreach (var dependency in resource.Dependencies)
                {
                    var dependencyResource = dependency.Resource;

                    if (dependencyResource == null)
                    {
                        Console.WriteLine($"ERROR: Unable to resolve dependency for \"{dependency.Key}\"");
                    }
                    else
                    {
                        dependencyResource.Dependants.dependencies.Add(new ProjectResourceDependency(projectExplorer, resource.FullName, dependency.metdadata));
                    }
                }
            }

            // 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.FullName, resource);
                }
            }

            projectExplorer.Tags = new PackageTagsCollection(tags);

            return(projectExplorer);
        }