/// <summary> /// Creates a new set of configs /// </summary> /// <param name="build">Optionally loads build specific config values</param> public void Create(uint build = 0) { CDNsFile = new VariableConfig(ConfigType.CDNs); VersionsFile = new VariableConfig(ConfigType.Versions); BuildConfig = new KeyValueConfig(ConfigType.BuildConfig); CDNConfig = new KeyValueConfig(ConfigType.CDNConfig); }
/// <summary> /// Loads the Build, CDN and Patch configs from disk /// </summary> /// <param name="directory">Directory containing the config files</param> public void OpenLocal(string directory, ManifestContainer manifestContainer) { if (manifestContainer?.VersionsFile == null || manifestContainer?.CDNsFile == null) { throw new Exception("Versions and CDNs files must be loaded first"); } if (!manifestContainer.VersionsFile.HasLocale(manifestContainer.Locale)) { throw new Exception($"Versions missing {manifestContainer.Locale} locale"); } if (manifestContainer.BuildConfigMD5.Value != null) { BuildConfig = new KeyValueConfig(manifestContainer.BuildConfigMD5.ToString(), directory, ConfigType.BuildConfig); } if (manifestContainer.CDNConfigMD5.Value != null) { CDNConfig = new KeyValueConfig(manifestContainer.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); } } }
/// <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); } } }
/// <summary> /// Opens the CDNs, Versions from Ribbit and the config files from Blizzard's CDN /// </summary> public void OpenRemote(ManifestContainer manifestContainer) { if (manifestContainer?.VersionsFile == null || manifestContainer?.CDNsFile == null) { throw new Exception("Versions and CDNs files must be loaded first"); } if (!manifestContainer.VersionsFile.HasLocale(manifestContainer.Locale)) { throw new Exception($"Versions missing {manifestContainer.Locale} locale"); } var cdnClient = new CDNClient(manifestContainer); if (manifestContainer.BuildConfigMD5.Value != null) { string configUrl = Helpers.GetCDNUrl(manifestContainer.BuildConfigMD5.ToString(), "config"); BuildConfig = new KeyValueConfig(cdnClient.OpenStream(configUrl).Result, ConfigType.BuildConfig); } if (manifestContainer.CDNConfigMD5.Value != null) { string configUrl = Helpers.GetCDNUrl(manifestContainer.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); } }
/// <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); } }
/// <summary> /// Opens the config files from disk /// </summary> /// <param name="directory"></param> /// <param name="buildConfigMD5"></param> /// <param name="cdnConfigMD5"></param> /// <param name="patchConfigMD5"></param> public void OpenLocal(string directory, string buildConfigMD5, string cdnConfigMD5, string patchConfigMD5 = null) { if (!string.IsNullOrWhiteSpace(buildConfigMD5)) { BuildConfig = new KeyValueConfig(buildConfigMD5, directory, ConfigType.BuildConfig); } if (!string.IsNullOrWhiteSpace(cdnConfigMD5)) { CDNConfig = new KeyValueConfig(cdnConfigMD5, directory, ConfigType.CDNConfig); } // optionally load the patch config if (!string.IsNullOrWhiteSpace(patchConfigMD5)) { string path = Helpers.GetCDNPath(patchConfigMD5, "config", directory); if (File.Exists(path)) { PatchConfig = new KeyValueConfig(patchConfigMD5, directory, ConfigType.PatchConfig); } } }
/// <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); } } }
/// <summary> /// Creates a new set of configs /// </summary> /// <param name="build">Optionally loads build specific config values</param> public void Create() { BuildConfig = new KeyValueConfig(ConfigType.BuildConfig); CDNConfig = new KeyValueConfig(ConfigType.CDNConfig); }