示例#1
0
        /// <summary>
        /// Loads the Build, CDN and Patch configs
        /// </summary>
        /// <param name="directory"></param>
        /// <param name="locale"></param>
        private void LoadConfigs(string directory)
        {
            if (VersionsFile == null || CDNsFile == null)
            {
                throw new Exception("Versions and CDNs files must be loaded first");
            }

            if (!VersionsFile.HasLocale(Locale))
            {
                throw new Exception($"Versions missing {Locale} locale");
            }

            if (BuildConfigMD5.Value != null)
            {
                BuildConfig = new KeyValueConfig(BuildConfigMD5.ToString(), directory, ConfigType.BuildConfig);
            }

            if (CDNConfigMD5.Value != null)
            {
                CDNConfig = new KeyValueConfig(CDNConfigMD5.ToString(), directory, ConfigType.CDNConfig);
            }

            // optionally load the patch config
            if (PatchConfigMD5.Value != null)
            {
                string path = Helpers.GetCDNPath(PatchConfigMD5.ToString(), "config", directory);
                if (File.Exists(path))
                {
                    PatchConfig = new KeyValueConfig(PatchConfigMD5.ToString(), directory, ConfigType.PatchConfig);
                }
            }
        }
示例#2
0
        /// <summary>
        /// Loads the Build, CDN and Patch configs
        /// </summary>
        /// <param name="directory"></param>
        /// <param name="locale"></param>
        private void LoadConfigs(string directory)
        {
            if (VersionsFile == null || CDNsFile == null)
            {
                throw new Exception("Versions and CDNs files must be loaded first");
            }

            if (!VersionsFile.HasLocale(Locale))
            {
                throw new Exception($"Versions missing {Locale} locale");
            }

            if (!BuildConfigMD5.IsEmpty)
            {
                BuildConfig = new KeyValueConfig(BuildConfigMD5.ToString(), directory, ConfigType.BuildConfig);
            }

            if (!CDNConfigMD5.IsEmpty)
            {
                CDNConfig = new KeyValueConfig(CDNConfigMD5.ToString(), directory, ConfigType.CDNConfig);
            }

            if (!PatchConfigMD5.IsEmpty)
            {
                PatchConfig = new KeyValueConfig(PatchConfigMD5.ToString(), directory, ConfigType.PatchConfig);
            }
        }
示例#3
0
        /// <summary>
        /// Opens the CDNs, Versions from Ribbit and the config files from Blizzard's CDN
        /// </summary>
        public void OpenRemote()
        {
            var ribbit = new RibbitClient(Locale);

            using (var cdnstream = ribbit.GetStream(RibbitCommand.CDNs, Product).Result)
                using (var verstream = ribbit.GetStream(RibbitCommand.Versions, Product).Result)
                {
                    CDNsFile     = new VariableConfig(cdnstream, ConfigType.CDNs);
                    VersionsFile = new VariableConfig(verstream, ConfigType.Versions);

                    if (!VersionsFile.HasLocale(Locale))
                    {
                        throw new Exception($"Versions missing {Locale} locale");
                    }

                    var cdnClient = new CDNClient(this);

                    if (BuildConfigMD5.Value != null)
                    {
                        string configUrl = Helpers.GetCDNUrl(BuildConfigMD5.ToString(), "config");
                        BuildConfig = new KeyValueConfig(cdnClient.OpenStream(configUrl).Result, ConfigType.BuildConfig);
                    }

                    if (CDNConfigMD5.Value != null)
                    {
                        string configUrl = Helpers.GetCDNUrl(CDNConfigMD5.ToString(), "config");
                        CDNConfig = new KeyValueConfig(cdnClient.OpenStream(configUrl).Result, ConfigType.CDNConfig);
                    }

                    if (PatchConfigMD5.Value != null)
                    {
                        string configUrl = Helpers.GetCDNUrl(PatchConfigMD5.ToString(), "config");
                        PatchConfig = new KeyValueConfig(cdnClient.OpenStream(configUrl).Result, ConfigType.PatchConfig);
                    }
                }
        }