Esempio n. 1
0
        public string GetAssetsIndex()
        {
            if (!string.IsNullOrEmpty(AssetsIndex))
            {
                return(AssetsIndex);
            }
            VersionManifest manifest = InheritableVersionManifest;

            while (true)
            {
                if (manifest.InheritsFrom == null)
                {
                    if (manifest.AssetsIndex != null)
                    {
                        return(manifest.AssetsIndex);
                    }
                    break;
                }
                manifest = manifest.InheritableVersionManifest;
            }
            throw new VersionCorrupted("Can't get assets index.")
                  {
                      Version = VersionId
                  };
        }
Esempio n. 2
0
        public static bool IsValid(DirectoryInfo pathToDirectory, bool throwsExceptions)
        {
            string version = pathToDirectory.Name;

            if (!File.Exists(Path.Combine(pathToDirectory.ToString(), version + ".json")))
            {
                if (throwsExceptions)
                {
                    throw new VersionCorruptedOrNotExists(
                              $"Directory '{version}' doesn't contain JSON file. Path: {pathToDirectory}")
                          {
                              Version = version
                          };
                }
                return(false);
            }
            VersionManifest ver = (VersionManifest)JsonConvert.DeserializeObject(File.ReadAllText(Path.Combine(pathToDirectory.ToString(), version + ".json")), typeof(VersionManifest));

            if (ver != null)
            {
                return(true);
            }
            if (throwsExceptions)
            {
                throw new VersionCorruptedOrNotExists(
                          $"Directory '{version}' contains corrupted JSON file. Path: {pathToDirectory}")
                      {
                          Version = version
                      };
            }
            return(false);
        }
Esempio n. 3
0
        /// <summary>
        /// Parses build's JSON file.
        /// </summary>
        /// <param name="pathToDirectory">Path to build's directory.</param>
        /// <param name="parseInheritableVersion">Parses inheritable builds.</param>
        public static VersionManifest ParseVersion(DirectoryInfo pathToDirectory, bool parseInheritableVersion)
        {
            IsValid(pathToDirectory, true);
            string          version = pathToDirectory.Name;
            VersionManifest ver     =
                (VersionManifest)
                JsonConvert.DeserializeObject(
                    File.ReadAllText(Path.Combine(pathToDirectory.ToString(), version + ".json")),
                    typeof(VersionManifest));

            if (ver.InheritsFrom == null || !parseInheritableVersion)
            {
                return(ver);
            }
            ver.InheritableVersionManifest =
                ParseVersion(new DirectoryInfo(Path.Combine(pathToDirectory.Parent.FullName, ver.InheritsFrom)));
            ver.Libs.AddRange(ver.InheritableVersionManifest.Libs);
            return(ver);
        }