Beispiel #1
0
        public LoadManifestsResult LoadAllManifests(IEnumerable <string> yamlFiles)
        {
            LoadManifestsResult result = new LoadManifestsResult();
            Dictionary <string, MultiFileYaml> multiFileYamlDict = new Dictionary <string, MultiFileYaml>();

            foreach (string yamlFilePath in yamlFiles)
            {
                ReadYamlFileResult ryfr = ReadYamlFile(yamlFilePath);
                if (ryfr.ErrorMessage != null)
                {
                    result.Messages.Add(yamlFilePath + ": " + ryfr.ErrorMessage);
                    continue;
                }
                ManifestPackage_1_0_0 package = ryfr.Manifest;

                string        yamlFolder    = Path.GetDirectoryName(yamlFilePath);
                MultiFileYaml multiFileYaml = null;
                if (multiFileYamlDict.TryGetValue(yamlFolder, out multiFileYaml) == false)
                {
                    multiFileYaml = new MultiFileYaml();
                    multiFileYamlDict.Add(yamlFolder, multiFileYaml);
                }
                multiFileYaml.AddPackage(package, yamlFilePath);
            }
            result.Manifests = multiFileYamlDict.Values;
            return(result);
        }
Beispiel #2
0
        public void SaveMultiFileYaml(MultiFileYaml mfy, string versionFolder)
        {
            string yamlTargetFilename = Path.GetFileName(mfy.MainYamlFilePath);
            string yamlTargetFilePath = Path.Combine(versionFolder, yamlTargetFilename);

            string packageIdentifier = mfy.MainPackage.PackageIdentifier;

            WriteYamlFile(Path.Combine(versionFolder, $"{packageIdentifier}.yaml"), mfy.MainPackage);
            if (mfy.MainPackage.ManifestType == "singleton")
            {
                return;
            }
            WriteYamlFile(Path.Combine(versionFolder, $"{packageIdentifier}.installer.yaml"), mfy.InstallerPackage);
            WriteYamlFile(Path.Combine(versionFolder, $"{packageIdentifier}.locale.{mfy.DefaultLocalePackage.PackageLocale}.yaml"), mfy.DefaultLocalePackage);
            foreach (ManifestPackage_1_0_0 localePackage in mfy.LocalePackages)
            {
                WriteYamlFile(Path.Combine(versionFolder, $"{packageIdentifier}.locale.{localePackage.PackageLocale}.yaml"), localePackage);
            }
        }
Beispiel #3
0
        public MultiFileYaml LoadMultiFileYaml(string mainYamlFilePath)
        {
            var ryr = ReadYamlFile(mainYamlFilePath);

            if (ryr.ErrorMessage != null)
            {
                return(null);               //todo
            }
            MultiFileYaml result = new MultiFileYaml();

            result.AddPackage(ryr.Manifest, mainYamlFilePath);
            if (result.MainPackage.ManifestType == "version")
            {
                string packageIdentifier = result.MainPackage.PackageIdentifier;
                string folder            = Path.GetDirectoryName(mainYamlFilePath);
                string installerFilePath = $"{packageIdentifier}.installer.yaml";
                var    ryri = ReadYamlFile(Path.Combine(folder, installerFilePath));
                if (ryri.ErrorMessage != null)
                {
                    return(null);                   //todo
                }
                result.AddPackage(ryri.Manifest, installerFilePath);
                string[] yamlFilePaths = Directory.GetFiles(folder, $"{packageIdentifier}.locale.*.yaml", SearchOption.TopDirectoryOnly);
                foreach (string yamlFilePath in yamlFilePaths)
                {
                    ReadYamlFileResult localeManifestResult = ReadYamlFile(Path.Combine(folder, yamlFilePath));
                    if (localeManifestResult.ErrorMessage != null)
                    {
                        return(null);                       //todo
                    }

                    result.AddPackage(localeManifestResult.Manifest, yamlFilePath);
                }
            }
            return(result);
        }