public static CASCConfig LoadOnlineStorageConfig() { var config = new CASCConfig(); string usingRegion = null; try { usingRegion = Constants.CDN_REGIONS[0]; using (var stream = CDNIndexHandler.OpenFileDirect(string.Format(Constants.CDN_CONFIG_URL, usingRegion))) config.CDNData = VerBarConfig.ReadVerBarConfig(stream); using (Stream stream = CDNIndexHandler.OpenFileDirect(string.Format(Constants.CDN_VERSION_URL, usingRegion))) config.VersionsData = VerBarConfig.ReadVerBarConfig(stream); } catch { usingRegion = Constants.CDN_REGIONS[1]; using (var stream = CDNIndexHandler.OpenFileDirect(string.Format(Constants.CDN_CONFIG_URL, usingRegion))) config.CDNData = VerBarConfig.ReadVerBarConfig(stream); using (Stream stream = CDNIndexHandler.OpenFileDirect(string.Format(Constants.CDN_VERSION_URL, usingRegion))) config.VersionsData = VerBarConfig.ReadVerBarConfig(stream); } if (usingRegion == null) { throw new Exception("Unable to access default CDN servers for config/versioning."); } for (int i = 0; i < config.VersionsData.Count; i++) { if (config.VersionsData[i]["Region"] == usingRegion) { config.versionIndex = i; break; } } string cdnKey = config.VersionsData[config.versionIndex]["CDNConfig"].ToLower(); using (Stream stream = CDNIndexHandler.OpenConfigFileDirect(config, cdnKey)) config.CDNConfig = KeyValueConfig.ReadKeyValueConfig(stream); config.ActiveBuild = 0; config.Builds = new List <KeyValueConfig>(); string buildKey = config.VersionsData[config.versionIndex]["BuildConfig"].ToLower(); using (Stream stream = CDNIndexHandler.OpenConfigFileDirect(config, buildKey)) { KeyValueConfig buildConfig = KeyValueConfig.ReadKeyValueConfig(stream); config.Builds.Add(buildConfig); } return(config); }
private CASCEngine(CASCConfig config) { Config = config; Log.Write("CASC: Loading indexes..."); CDNIndex = CDNIndexHandler.Initialize(config); Log.Write("CASC: Loaded {0} indexes", CDNIndex.Count); if (!Program.Settings.UseRemote) { CDNIndexHandler.Cache.Enabled = false; Log.Write("CASC: Loading indexes from local storage..."); LocalIndex = LocalIndexHandler.Initialize(config); Log.Write("CASC: Loaded {0} indexes from local storage", LocalIndex.Count); } EventManager.Trigger_LoadStepDone(); Log.Write("CASC: Loading encoding data..."); using (var stream = OpenEncodingFile(this)) EncodingHandler = new EncodingHandler(stream); Log.Write("CASC: Loaded {0} encoding data entries", EncodingHandler.Count); if ((CASCConfig.LoadFlags & LoadFlags.Download) != 0) { Log.Write("CASC: Loading download data..."); using (var stream = OpenDownloadFile(EncodingHandler, this)) DownloadHandler = new DownloadHandler(stream); Log.Write("CASC: Loaded {0} download data entries", EncodingHandler.Count); } EventManager.Trigger_LoadStepDone(); Log.Write("CASC: Loading root data..."); using (var stream = OpenRootFile(EncodingHandler, this)) RootHandler = new RootHandler(stream); Log.Write("CASC: Loaded {0} root data entries", RootHandler.Count); if ((CASCConfig.LoadFlags & LoadFlags.Install) != 0) { Log.Write("CASC: Loading install data..."); using (var stream = OpenInstallFile(EncodingHandler, this)) InstallHandler = new InstallHandler(stream); Log.Write("CASC: Loaded {0} install data entries", InstallHandler.Count); } EventManager.Trigger_LoadStepDone(); }
public void Clear() { CDNIndex?.Clear(); CDNIndex = null; foreach (var stream in DataStreams) { stream.Value.Dispose(); } }
public static CDNIndexHandler Initialize(CASCConfig config) { CDNIndexHandler handler = new CDNIndexHandler(config); for (int i = 0; i < config.Archives.Count; i++) { string archive = config.Archives[i]; if (Program.Settings.UseRemote) handler.DownloadIndexFile(archive, i); else handler.OpenIndexFile(archive, i); } return handler; }
public static CDNIndexHandler Initialize(CASCConfig config) { CDNIndexHandler handler = new CDNIndexHandler(config); for (int i = 0; i < config.Archives.Count; i++) { string archive = config.Archives[i]; if (Program.Settings.UseRemote) { handler.DownloadIndexFile(archive, i); } else { handler.OpenIndexFile(archive, i); } } return(handler); }
public void Clear() { CDNIndex?.Clear(); CDNIndex = null; foreach (var stream in DataStreams) stream.Value.Dispose(); }