/// <summary> /// Interprets the ScpControl.ini configuration file. /// </summary> private IniConfig() { var ini = new IniFile(); var fullPath = Path.Combine(WorkingDirectory, CfgFile); if (!File.Exists(fullPath)) { Log.FatalFormat("Configuration file {0} not found!", fullPath); return; } // parse data from INI try { ini.Load(fullPath); string[] values; BthDongle = new BthDongleCfg(); { ini.Sections["BthDongle"].Keys["SupportedNames"].TryParseValue(out values); BthDongle.SupportedNames = values; ini.Sections["BthDongle"].Keys["SupportedMacs"].TryParseValue(out values); BthDongle.SupportedMacs = values; } BthDs3 = new BthDs3Cfg(); { ini.Sections["BthDs3"].Keys["SupportedNames"].TryParseValue(out values); BthDs3.SupportedNames = values; ini.Sections["BthDs3"].Keys["SupportedMacs"].TryParseValue(out values); BthDs3.SupportedMacs = values; } } catch (Exception ex) { Log.FatalFormat("Error while parsing configuration file: {0}", ex); } }
/// <summary> /// Interprets the ScpControl.ini configuration file. /// </summary> private IniConfig() { var iniOpts = new IniOptions() { CommentStarter = IniCommentStarter.Semicolon, KeyDuplicate = IniDuplication.Allowed }; var ini = new IniFile(iniOpts); var fullPath = Path.Combine(WorkingDirectory, CfgFile); if (!File.Exists(fullPath)) { Log.FatalFormat("Configuration file {0} not found!", fullPath); return; } // parse data from INI try { ini.Load(fullPath); BthDongle = new BthDongleCfg() { SupportedNames = ini.Sections["BthDongle"].Keys.Where(k => k.Name == "SupportedName").Select(v => v.Value), SupportedMacs = ini.Sections["BthDongle"].Keys.Where(k => k.Name == "SupportedMac").Select(v => v.Value) }; BthDs3 = new BthDs3Cfg() { SupportedNames = ini.Sections["BthDs3"].Keys.Where(k => k.Name == "SupportedName").Select(v => v.Value), SupportedMacs = ini.Sections["BthDs3"].Keys.Where(k => k.Name == "SupportedMac").Select(v => v.Value) }; Hci = new HciCfg() { SupportedNames = ini.Sections["HCI"].Keys.Where(k => k.Name == "SupportedName").Select(v => v.Value) }; Ds3Driver = new Ds3DriverCfg() { DeviceGuid = ini.Sections["DualShock 3 Controllers"].Keys["DeviceGuid"].Value, HardwareIds = ini.Sections["DualShock 3 Controllers"].Keys.Where(k => k.Name == "HardwareId").Select(v => v.Value) }; Ds4Driver = new Ds4DriverCfg() { DeviceGuid = ini.Sections["DualShock 4 Controllers"].Keys["DeviceGuid"].Value, HardwareIds = ini.Sections["DualShock 4 Controllers"].Keys.Where(k => k.Name == "HardwareId").Select(v => v.Value) }; BthDongleDriver = new BthDongleDriverCfg() { DeviceGuid = ini.Sections["Bluetooth Dongles"].Keys["DeviceGuid"].Value, HardwareIds = ini.Sections["Bluetooth Dongles"].Keys.Where(k => k.Name == "HardwareId").Select(v => v.Value) }; } catch (Exception ex) { Log.FatalFormat("Error while parsing configuration file: {0}", ex); } }