Esempio n. 1
0
        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;
        }
Esempio n. 2
0
        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());
        }
Esempio n. 3
0
        public static void Save(string fileName, GenericPropertyCollection properties)
        {
            var jArrayProperties = GenericPropertySerializer.SerializePropertiesToArray(properties);

            File.WriteAllText(fileName, jArrayProperties.ToString(), Encoding.UTF8);
        }