private void Initialize(string fileName) { if (!File.Exists(fileName)) { throw new Exception(string.Format("指定的文件不存在!{0}", fileName)); } var iniFile = new WinIniFile(fileName); // Parse Local Port. var value = iniFile.ReadValue("Local", "Port"); this.LocalEndPoint.Port = (int)SettingsParser.ParseDecimal(value); // var index = 1; while (index <= 100) { var section = string.Format("Remote{0}", index++); var keys = iniFile.ReadValue(section, null); if (string.IsNullOrEmpty(keys)) { continue; } var remoteId = (ushort)SettingsParser.ParseDecimal(iniFile.ReadValue(section, "ID")); var endPoint = SettingsParser.ParseIPEndPoint(iniFile.ReadValue(section, "IPEndPoint")); this.RemoteEndPoints.Add(remoteId, endPoint); } }
public void Setting_name_is_required() { var line = "G195 malformed"; var sut = new SettingsParser(); sut.ExtractLine(line); }
private static bool ProcessInit() { try { var gateway = PluginBase.GetGatewayFactory().Invoke(); // загружаем настройки плагина _settings = SettingsParser.LoadMapping(_iniConfig); // чтобы SCN_MODIFIED вызывался только, если был добавлен или удален текст gateway.SetModEventMask((int)SciMsg.SC_MOD_INSERTTEXT | (int)SciMsg.SC_MOD_DELETETEXT); // NPPN_READY вызывается перед последним вызовом NPPN_BUFFERACTIVATED, поэтому нужно инициализировать SearchEngine SearchEngine.Reload(_settings, gateway.GetFullCurrentPath()); // инициализация обработчика кликов мышкой UserInputHandler.Reload(HandleMouseEvent, OnKeyboardDown); // инициализация поддержки кнопок navigate forward/backward NavigationHandler.Reload(gateway.GetCurrentLocation()); // инициализация поддержки подсветки ссылок _linksHighlighter?.Dispose(); _linksHighlighter = new LinksHighlighter(gateway, _settings); // при запуске NPP вызывается миллиард событий, в том числе и интересующие нас NPPN_BUFFERACTIVATED, SCN_MODIFIED, etc. Но их не нужно обрабатывать до инициализации. _isPluginInited = true; return(true); } catch (Exception e) { Logger.Error(e.Message, e, true); return(false); } }
public void SettingsParser_Parse_SettingsWithReservedKey_ReturnsExpectedResult() { var sp = new SettingsParser(); var reader = GetSettingsFileReader(SettingsWithReservedKey); sp.Parse(reader.ReadSettings(), "Dev", '|'); }
public void UnPopulatedConfigIsNotValid() { var raw = new RawConfiguration(); var settings = SettingsParser.ParseToSettings(raw); Assert.That(settings, Is.Null); }
public void ReturnCorrectValuesAccordingToArgs() { var serverBackupDir = "1"; var serverInstallDir = "2"; var steamcmdDownloadUrl = "3"; var steamcmdInstallDir = "4"; var timeZone = "5"; var settings = SettingsParser.ParseArgs(CesxSettings.Default, new[] { "--server_backup_dir", serverBackupDir, "--server_install_dir", serverInstallDir, "--steamcmd_download_url", steamcmdDownloadUrl, "--steamcmd_install_dir", steamcmdInstallDir, "--time_zone", timeZone, "--skip_backup", "--skip_update" }); Assert.Equal(serverBackupDir, settings.ServerBackupDir); Assert.Equal(serverInstallDir, settings.ServerInstallDir); Assert.Equal(steamcmdDownloadUrl, settings.SteamCmdDownloadUrl); Assert.Equal(steamcmdInstallDir, settings.SteamCmdInstallDir); Assert.Equal(timeZone, settings.TimeZone); Assert.True(settings.SkipBackup); Assert.True(settings.SkipUpdate); }
private void BuildLocalSafetyParameter() { this.LocalSafetyParam = new SafetyParameters(); // address //var localAddrs = SettingsParser.ParseDictionary(_iniFile.ReadValue("Local", "Address"), new String[] { ",", "," }, new string[] { "=>" }); //if (localAddrs.Count < 2) throw new Exception(string.Format("Local.Address个数不能小于2。")); //this.LocalSafetyParam.Addr = (ushort)localAddrs[this.LocalCodeInAts]; this.LocalSafetyParam.Addr = (ushort)SettingsParser.ParseDecimal(_iniFile.ReadValue("Local", "Address")); var sid = SettingsParser.ParseDecimals(_iniFile.ReadValue("Local", "SID"), new string[] { ",", "," }); if (sid.Count < 2) { throw new Exception(string.Format("Local.SID个数不能小于2。")); } this.LocalSafetyParam.SID = sid.Select(p => (uint)p).ToArray(); // SINIT var sinit = SettingsParser.ParseDecimals(_iniFile.ReadValue("Local", "SINIT"), new string[] { ",", "," }); if (sinit.Count < 2) { throw new Exception(string.Format("Local.SINIT个数不能小于2。")); } this.LocalSafetyParam.SINIT = sinit.Select(p => (uint)p).ToArray(); // DataVersion var dataVer = SettingsParser.ParseDecimals(_iniFile.ReadValue("Local", "DATAVER"), new string[] { ",", "," }); if (dataVer.Count < 2) { throw new Exception(string.Format("Local.DATAVER个数不能小于2。")); } this.LocalSafetyParam.DATAVER = dataVer.Select(p => (uint)p).ToArray(); }
/// <summary> /// Gets the tax exemption. /// </summary> /// <param name="tax_exemption_id">The tax_exemption_id.</param> /// <returns>TaxExemption.</returns> public TaxExemption GetTaxExemption(string tax_exemption_id) { var url = baseAddress + "/taxexemption/" + tax_exemption_id; var response = ZohoHttpClient.get(url, getQueryParameters()); return(SettingsParser.getTaxExemption(response)); }
/// <summary> /// Deletes the tax exemption. /// </summary> /// <param name="tax_exemption_id">The tax_exemption_id.</param> /// <returns>System.String.</returns> public string DeleteTaxExemption(string tax_exemption_id) { var url = baseAddress + "/taxexemptions/" + tax_exemption_id; var response = ZohoHttpClient.delete(url, getQueryParameters()); return(SettingsParser.getMessage(response)); }
/// <summary> /// Deletes the tax authority. /// </summary> /// <param name="tax_authority_id">The tax_authority_id.</param> /// <returns>System.String.</returns> public string DeleteTaxAuthority(string tax_authority_id) { var url = baseAddress + "/taxauthorities/" + tax_authority_id; var response = ZohoHttpClient.delete(url, getQueryParameters()); return(SettingsParser.getMessage(response)); }
/// <summary> /// Gets the tax exemptions. /// </summary> /// <returns>TaxExemptionList.</returns> public TaxExemptionList GetTaxExemptions() { var url = baseAddress + "/taxexemptions"; var response = ZohoHttpClient.get(url, getQueryParameters()); return(SettingsParser.getTaxExemptionList(response)); }
/// <summary> /// Gets the tax authorites. /// </summary> /// <returns>TaxAuthorityList.</returns> public TaxAuthorityList GetTaxAuthorites() { var url = baseAddress + "/taxauthorities"; var response = ZohoHttpClient.get(url, getQueryParameters()); return(SettingsParser.getTaxAuthorityList(response)); }
/// <summary> /// Gets the details of a tax group with associated taxes. /// </summary> /// <param name="tax_group_id">The tax_group_id is the identifier of the tax group.</param> /// <returns>TaxGroup object.</returns> public TaxGroup GetTaxGroup(string tax_group_id) { var url = baseAddress + "/taxgroups/" + tax_group_id; var response = ZohoHttpClient.get(url, getQueryParameters()); return(SettingsParser.getTaxGroup(response)); }
/// <summary> /// Delete an exchange rate for the specified currency. /// </summary> /// <param name="currency_id">The currency_id is the identifier of the currency.</param> /// <param name="exchange_rate_id"> /// The exchange_rate_id is the identifier of the exchange rate which is configured for the /// specified currency. /// </param> /// <returns>System.String.<br></br>The success message is "Exchange rate successfully deleted"</returns> public string DeleteAnExchangeRate(string currency_id, string exchange_rate_id) { var url = baseAddress + "/currencies/" + currency_id + "/exchangerates/" + exchange_rate_id; var response = ZohoHttpClient.delete(url, getQueryParameters()); return(SettingsParser.getMessage(response)); }
/// <summary> /// List of preferences that are configured. /// </summary> /// <returns>Preferences object.</returns> public Preferences GetPreferences() { var url = baseAddress + "/preferences"; var response = ZohoHttpClient.get(url, getQueryParameters()); return(SettingsParser.getPreferences(response)); }
//---------------------------------------------------------------------------------------- /// <summary> /// Gets the opening balance. /// </summary> /// <returns>OpeningBalance object.</returns> public OpeningBalance GetOpeningBalance() { var url = baseAddress + "/openingbalances"; var response = ZohoHttpClient.get(url, getQueryParameters()); return(SettingsParser.getOpeningBalance(response)); }
private void reloadMappingButton_Click(object sender, EventArgs e) { var mappingRemoteUrl = _mappingRemoteUrlTextBoxWrapper.GetText(); var result = MessageBox.Show($@"Do you really want to reload mapping from: <{mappingRemoteUrl}>?", @"Reload mapping?", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (result != DialogResult.OK) { return; } Uri uri; try { uri = ConvertUtils.ToUri(mappingRemoteUrl); } catch (Exception) { return; } try { SettingsParser.DownloadRemoteMapping(uri); Logger.InfoBox($"Mapping successfully reloaded from: {uri}"); } catch (Exception) { Logger.Error($"cannot reload mapping by remote URL: \"{uri}\".", null, true); } }
/// <summary> /// Delete the entered opening balance. /// </summary> /// <returns>System.String.<br></br>The success message is "The entered opening balance has been deleted."</returns> public string DeleteOpeningBalance() { var url = baseAddress + "/openingbalances"; var response = ZohoHttpClient.delete(url, getQueryParameters()); return(SettingsParser.getMessage(response)); }
public void Should_be_able_to_extract_name_from_a_line() { var line = "G195=Out:LED0799,LED0814,Flags:L-N Desc:\"EAF-QCH-B1-01\" Invert:00 STO:35 SP:0 FStart: FStop: "; var sut = new SettingsParser(); var actual = sut.ExtractLine(line); Assert.AreEqual("G195", actual.Name); }
//--------------------------------------------------------------------------------------------- /// <summary> /// List of automated payment reminders. /// </summary> /// <returns>List of AutoReminder object.</returns> public AutoReminderList GetAutoPaymentReminders() { var url = baseAddress + "/autoreminders"; var response = ZohoHttpClient.get(url, getQueryParameters()); return(SettingsParser.getAutoReminderList(response)); }
private SafetyParameters CreateRemoteSafetyParameters(string section) { var remoteSafetyParam = new SafetyParameters(); // Address remoteSafetyParam.Addr = (ushort)SettingsParser.ParseDecimal(_iniFile.ReadValue(section, "Address")); // SID var sid = SettingsParser.ParseDecimals(_iniFile.ReadValue(section, "SID"), new string[] { ",", "," }); if (sid.Count < 2) { throw new Exception(string.Format("{0}.SID个数不能小于2。", section)); } remoteSafetyParam.SID = sid.Select(p => (uint)p).ToArray(); // SINIT var sinit = SettingsParser.ParseDecimals(_iniFile.ReadValue(section, "SINIT"), new string[] { ",", "," }); if (sinit.Count < 2) { throw new Exception(string.Format("{0}.SINIT个数不能小于2。", section)); } remoteSafetyParam.SINIT = sinit.Select(p => (uint)p).ToArray(); // DataVersion var dataVer = SettingsParser.ParseDecimals(_iniFile.ReadValue(section, "DATAVER"), new string[] { ",", "," }); if (dataVer.Count < 2) { throw new Exception(string.Format("{0}.DATAVER个数不能小于2。", section)); } remoteSafetyParam.DATAVER = dataVer.Select(p => (uint)p).ToArray(); return(remoteSafetyParam); }
/// <summary> /// Get the details of an automated payment reminder. /// </summary> /// <param name="template_id"> /// The template_id is the identifier of the template in which format it the reminder is going to /// send to the customer. /// </param> /// <returns>AutoReminderAndPlaceHolders object.</returns> public AutoReminderAndPlaceHolders GetAnAutoPaymentReminder(string template_id) { var url = baseAddress + "/autoreminders/" + template_id; var response = ZohoHttpClient.get(url, getQueryParameters()); return(SettingsParser.getAutoReminderAndPlaceHolders(response)); }
public void SettingsParser_Parse_with_invalid_section_throws_exception() { var sp = new SettingsParser(); var reader = GetSettingsFileReader(Basic); sp.Parse(reader.ReadSettings(), "AAAA", '|'); }
/// <summary> /// Disable an automated payment reminder. /// </summary> /// <param name="reminder_id">The reminder_id is the identifier of the auto reminder.</param> /// <returns>System.String.<br></br>The success message is "Payment reminder has been disabled."</returns> public string DisableAutoReminder(string reminder_id) { var url = baseAddress + "/autoreminders/" + reminder_id + "/disable"; var response = ZohoHttpClient.post(url, getQueryParameters()); return(SettingsParser.getMessage(response)); }
protected override void OnWindowLoaded(object sender, RoutedEventArgs e) { SettingsParser parser = new SettingsParser(); //if it's not launched from the main window, then the ModpackSettings object has not been parsed yet. do that now. if (!LaunchedFromMainWindow) { //TODO: use hook for functions that normally happen in the MainWindow? } //also load the feature window's custom settings file parser.LoadSettings(Settings); //load base classes method base.OnWindowLoaded(sender, e); //if not skipping update, and not launched from the main window, then run a stand-alone update check if (!LaunchedFromMainWindow && !CommandLineSettings.SkipUpdate && RunStandAloneUpdateCheck) { Task.Run(async() => { if (!await CommonUtils.IsManagerUptoDate(CommonUtils.GetApplicationVersion(), ModpackSettings.ApplicationDistroVersion)) { MessageBox.Show("Your application is out of date. Please launch the application normally to update"); } }); } }
/// <summary> /// Delete a unit that has been associated to an item. /// </summary> /// <param name="unit_id">The unit_id.</param> /// <returns>System.String.<br></br>The success message is "You have successfully deleted the unit."</returns> public string DeleteUnit(string unit_id) { var url = baseAddress + "/units/" + unit_id; var response = ZohoHttpClient.delete(url, getQueryParameters()); return(SettingsParser.getMessage(response)); }
public void equals_must_be_before_first_colon() { var line = "G195:malformed name=value"; var sut = new SettingsParser(); sut.ExtractLine(line); }
/// <summary> /// List of manual reminders. /// </summary> /// <param name="parameters"> /// The parameters is the dictionary object which contains the following filter in the form of key,value pair.<br></br> /// <table> /// <tr> /// <td>type</td> /// <td> /// Type to select between open or overdue reminder.<br></br>Allowed Values: <i>overdue_reminder</i> and /// <i>open_reminder</i> /// </td> /// </tr> /// </table> /// </param> /// <returns>List of Manualreminder object.</returns> public ManualReminderList GetManualReminders(Dictionary <object, object> parameters) { var url = baseAddress + "/manualreminders"; var response = ZohoHttpClient.get(url, getQueryParameters(parameters)); return(SettingsParser.getManualReminderList(response)); }
private void Upsert(UserMacro item = null) { var isNew = item == null; if (isNew) { item = new UserMacro(); } item.Name = NameTextBox.Text; item.Text = MacroText.Text; item.MapType = (int)SettingsParser.TryParseValue(MapTypeComboBox.Text, MapType.Button); item.MapIndex = SettingsParser.TryParseValue(MapIndexTextBox.Text, 0); item.MapEventType = (int)SettingsParser.TryParseValue(MapEventTypeComboBox.Text, MapEventType.EnterUpLeaveDown); item.MapRpmType = (int)SettingsParser.TryParseValue(MapRpmTypeComboBox.Text, MapRpmType.DownIncrease); item.MapRangeMin = SettingsParser.TryParseValue(MapRangeMin.Text, 0); item.MapRangeMax = SettingsParser.TryParseValue(MapRangeMin.Text, 0); item.MapRpmMin = SettingsParser.TryParseValue(MapRpmMin.Text, 0); item.MapRpmMax = SettingsParser.TryParseValue(MapRpmMax.Text, 0); // Assing to current controller. item.SettingId = _UserSetting.SettingId; if (isNew) { SettingsManager.UserMacros.Add(item); } }
/// <summary> /// Get the details of a manual reminder. /// </summary> /// <param name="reminder_id">The reminder_id is the identifier of the existing manual reminder.</param> /// <returns>ManualReminderAndPlaceHolders object.</returns> public ManualReminderAndPlaceHolders GetManualReminder(string reminder_id) { var url = baseAddress + "/manualreminders/" + reminder_id; var response = ZohoHttpClient.get(url, getQueryParameters()); return(SettingsParser.getManualReminderAndPlaceHolders(response)); }
private void applyBtn_Click(object sender, EventArgs e) { SetAllSettings(); var parser = new SettingsParser(); // Save settings Batch.UpdateSettings(Settings); Hide(); }
public void ViaFastInvoke() { var commandLine = @"-Website:cue -Database:cue_db -YesNo:true -Auto:Manual"; var p = new SettingsParser(); var r = (TestSettings)p.FastInvoke<SettingsParser, object>(new []{typeof(TestSettings)}, "Parse", new FileInfo("."), commandLine, "test"); Assert.AreEqual("cue_db", r.Database); Assert.AreEqual("cue", r.Website); Assert.IsTrue(r.YesNo); Assert.AreEqual(SampleEnum.Manual, r.Auto); }
public void ParseTheContentToObject() { File.WriteAllText(".\\test.json","{Website:\"cue\",Database:\"cue_db\",YesNo:true,Auto:\"Manual\"}"); var commandLine = @"-Website:cue -Database:cue_db -YesNo:true"; var p = new SettingsParser(); var r = p.Parse<TestSettings>(new FileInfo(".\\test.json"), commandLine, "test"); Assert.AreEqual("cue_db",r.Database); Assert.AreEqual("cue",r.Website); Assert.IsTrue(r.YesNo); Assert.AreEqual(SampleEnum.Manual, r.Auto); }