public static void Save(Configuration obj) { try { YamlFile.Serialize(obj, Specifications.APPCONFIG_FILENAME); s_logger.Info("Saved configuration."); } catch (Exception e) { s_logger.Error(e, "Failed to save configuration."); throw; } }
public static Configuration Load() { try { var config = YamlFile.Deserialize <Configuration>(Specifications.APPCONFIG_FILENAME); s_logger.Info("Configuration was loaded."); return(config); } catch (Exception e) { s_logger.Error(e, "Failed to load configuration. Initialize configuration by default."); var config = new Configuration(); Save(config); return(config); } }
internal LolClient(string directory, YamlFile properties, LolProxy proxy, Process process, ExtensionManager extManager) { if (proxy == null) { throw new ArgumentNullException("proxy"); } if (!Directory.Exists(directory)) { throw new ArgumentException("directory"); } //GameData = new LolClientGameData(Path.Combine(directory, GameDataFile)); //Images = new LolClientImages(directory, GameData); Connection = new LolConnection(proxy, extManager); Process = process; Properties = properties; ExtensionManager = extManager; }
void ProcessInjector_ProcessFound(object sender, Process e) { ProcessInjector pi = sender as ProcessInjector; if (pi == null) { return; } Thread.Sleep(1000); string loldir = null; try { loldir = Path.GetDirectoryName(e.MainModule.FileName) ?? string.Empty; } catch (Win32Exception) { MessageBox.Show("Cannot access the lolclient process. If this error persists try runnig as an administrator.", "Error"); return; } _lolProperties = new YamlFile(Path.Combine(loldir, LolPropertiesFilename)); _lcuSettings = new YamlFile(Path.Combine(loldir, LcuSettingsPath, LcuSettingsFilename)); //string host = ((dynamic)_lolProperties)["region_data"][((dynamic)_lcuSettings)["install"]["globals"]["region"]]["servers"]["lcds"]["lcds_host"]; _rtmpAddress = ((dynamic)_lolProperties)["region_data"][((dynamic)_lcuSettings)["install"]["globals"]["region"]]["servers"]["lcds"]["lcds_host"]; if (_rtmpAddress == null) { return; } _certificate = GetCertificate(_rtmpAddress); if (_certificate == null) { Dispatcher.Invoke(() => MessageBox.Show(this, "This program is not compatible with your region: " + _lolProperties["platformId"] + ".\n", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning)); return; } if (!IsInstalled(_certificate)) { MessageBoxResult res = MessageBoxResult.None; Dispatcher.Invoke(() => res = MessageBox.Show(this, "A certificate needs to be installed.\n\n" + "You can see which certificates are installed under Views->FinalesFunkeln->Certificates and uninstall them at any time.\n\nInstall the certificate now?", "Confirmation", MessageBoxButton.YesNo, MessageBoxImage.Information)); if (res != MessageBoxResult.Yes) { return; } InstallCertificate(_certificate); } InitProxy(); _lolClient = new LolClient(loldir, _lolProperties, _proxy, e, _extensionManager); _extensionManager.FireLolClientInjectedEvent(_lolClient); try { pi.Inject(); _lolClientProcess = e; } catch (WarningException ex) { //I think this only happens when we try to inject into an already redirected app. } catch (AccessViolationException ex) { //Not sure what to do if that happens if (Debugger.IsAttached) { Debugger.Break(); } } }