private void buttonSave_Click(object sender, EventArgs e) { var jObjectSettings = new JObject(); foreach (TabPage tabPage in tabControl.TabPages) { if (tabPage.Tag is HuntingType huntingType) { GenericPropertyCollection properties = null; foreach (Control control in tabPage.Controls) { if (control is GenericPropertyListControl propertyControl) { properties = propertyControl.Properties; } } if (properties != null) { jObjectSettings[huntingType.TypeName + Constants.HUNTING_PROPERTIES_POSTFIX] = GenericPropertySerializer.SerializePropertiesToArray(properties); } } } jObjectSettings[Constants.GENERAL_PROPERTIES] = GenericPropertySerializer.SerializePropertiesToArray(genericPropertyListControl.Properties); SettingsHelper.SaveSettings(jObjectSettings); DialogResult = DialogResult.OK; }
public static void Save(Dictionary <string, GenericPropertyCollection> properties, string fileName = "properties.json") { var jArrayProperties = new JArray(); foreach (var tradingServiceName in properties.Keys) { var jArrayTradingServiceProperties = GenericPropertySerializer.SerializePropertiesToArray(properties[tradingServiceName]); var jObjectProperties = new JObject() { ["tradingServiceName"] = tradingServiceName, ["properties"] = jArrayTradingServiceProperties }; jArrayProperties.Add(jObjectProperties); } File.WriteAllText(fileName, jArrayProperties.ToString()); }
public static void Save(string fileName, GenericPropertyCollection properties) { var jArrayProperties = GenericPropertySerializer.SerializePropertiesToArray(properties); File.WriteAllText(fileName, jArrayProperties.ToString(), Encoding.UTF8); }