예제 #1
0
        public static void Load(GenericPropertyCollection properties, string fileName)
        {
            var contents         = File.ReadAllText(fileName, Encoding.UTF8);
            var jArrayProperties = JArray.Parse(contents);

            GenericPropertySerializer.DeserializePropertiesFromArray(properties, jArrayProperties);
        }
예제 #2
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;
        }
예제 #3
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());
        }
예제 #4
0
        public virtual void Initialize()
        {
            Api = new BinanceApi();

            var apiKey    = genericProperties.Get(SettingName.API_KEY, string.Empty);
            var secretKey = genericProperties.Get(SettingName.SECRET_KEY, string.Empty);

            if (!string.IsNullOrEmpty(apiKey) && !string.IsNullOrEmpty(secretKey))
            {
                User = new BinanceApiUser(apiKey, secretKey);
            }

            var jArrayProperties = SettingsHelper.GetJArrayHuntingProperties(TypeName);

            if (jArrayProperties != null)
            {
                GenericPropertySerializer.DeserializePropertiesFromArray(Properties, jArrayProperties);
            }
        }
예제 #5
0
        public static GenericPropertyCollection GetGeneralProperties()
        {
            var properties = new GenericPropertyCollection()
            {
                new GenericProperty()
                {
                    Browsable    = true,
                    Name         = SettingName.API_KEY,
                    DisplayName  = "Api Key",
                    DefaultValue = string.Empty,
                    Type         = GenericPropertyType.String
                },
                new GenericProperty()
                {
                    Browsable    = true,
                    Name         = SettingName.SECRET_KEY,
                    DisplayName  = "Secret Key",
                    DefaultValue = string.Empty,
                    Type         = GenericPropertyType.String
                },
                new GenericProperty()
                {
                    Browsable    = true,
                    Name         = SettingName.TRADING_ENABLED,
                    DisplayName  = "Trading Enable",
                    DefaultValue = false,
                    Type         = GenericPropertyType.Boolean
                }
            };

            var jArrayProperties = GetJArrayGeneralProperties();

            if (jArrayProperties != null)
            {
                GenericPropertySerializer.DeserializePropertiesFromArray(properties, jArrayProperties);
            }

            return(properties);
        }
예제 #6
0
        private void FormSettings_Load(object sender, EventArgs e)
        {
            // general properties
            genericPropertyListControl.Properties = SettingsHelper.GetGeneralProperties();
            genericPropertyListControl.RefreshItems();

            // hunting properties
            var huntingTypes = HuntingTypeManager.Instance.HuntingTypes;

            foreach (var huntingType in huntingTypes)
            {
                var properties       = huntingType.GetProperties();
                var jArrayProperties = SettingsHelper.GetJArrayHuntingProperties(huntingType.TypeName);
                if (jArrayProperties != null)
                {
                    GenericPropertySerializer.DeserializePropertiesFromArray(properties, jArrayProperties);
                }

                var tabPage = new TabPage()
                {
                    Text = huntingType.DisplayName,
                    Tag  = huntingType
                };

                var propertyControl = new GenericPropertyListControl
                {
                    Dock       = DockStyle.Fill,
                    Properties = properties
                };
                propertyControl.Options.ViewMode = ViewMode.CategoryList;

                tabPage.Controls.Add(propertyControl);
                tabControl.TabPages.Add(tabPage);

                propertyControl.RefreshItems();
            }
        }
예제 #7
0
        public static void Save(string fileName, GenericPropertyCollection properties)
        {
            var jArrayProperties = GenericPropertySerializer.SerializePropertiesToArray(properties);

            File.WriteAllText(fileName, jArrayProperties.ToString(), Encoding.UTF8);
        }
예제 #8
0
        public static Project Load(string fileName)
        {
            var contents = File.ReadAllText(fileName, Encoding.UTF8);
            var jObject  = JObject.Parse(contents);
            var project  = new Project
            {
                Name        = JObjectHelper.GetStringValue(jObject, "name"),
                ProjectPath = JObjectHelper.GetStringValue(jObject, "projectPath"),
                OutputPath  = JObjectHelper.GetStringValue(jObject, "outputPath")
            };

            // obfuscation
            if (jObject["obfuscation"] != null)
            {
                var jObjectObfuscation = (JObject)jObject["obfuscation"];

                project.Obfuscation.Enabled = JObjectHelper.GetBoolValue(jObjectObfuscation, "enabled");

                project.Obfuscation.PluginName = JObjectHelper.GetStringValue(jObjectObfuscation, "pluginName");

                if (jObjectObfuscation["pluginParameters"] != null)
                {
                    var pluginInfo = PluginManager.Instance.GetPluginInfoByName(project.Obfuscation.PluginName);
                    if (pluginInfo != null)
                    {
                        var pluginProperties = pluginInfo.Plugin.GetProperties();
                        project.Obfuscation.PluginParameters = GenericPropertySerializer.DeserializeFromJArrayToDictionary(pluginProperties, (JArray)jObjectObfuscation["pluginParameters"]);
                    }
                }

                if (jObjectObfuscation["items"] != null)
                {
                    var jArrayObfuscationItems = (JArray)jObjectObfuscation["items"];

                    foreach (JObject jObjectObfuscationItem in jArrayObfuscationItems)
                    {
                        project.Obfuscation.Items.Add(new ObfuscationItem()
                        {
                            Selected = JObjectHelper.GetBoolValue(jObjectObfuscationItem, "selected"),
                            FileName = JObjectHelper.GetStringValue(jObjectObfuscationItem, "fileName")
                        });
                    }
                }
            }

            // signing
            if (jObject["signing"] != null)
            {
                var jObjectSigning = (JObject)jObject["signing"];

                project.Signing.Enabled = JObjectHelper.GetBoolValue(jObjectSigning, "enabled");

                project.Signing.PluginName = JObjectHelper.GetStringValue(jObjectSigning, "pluginName");

                if (jObjectSigning["pluginParameters"] != null)
                {
                    var pluginInfo = PluginManager.Instance.GetPluginInfoByName(project.Signing.PluginName);
                    if (pluginInfo != null)
                    {
                        var pluginProperties = pluginInfo.Plugin.GetProperties();
                        project.Signing.PluginParameters = GenericPropertySerializer.DeserializeFromJArrayToDictionary(pluginProperties, (JArray)jObjectSigning["pluginParameters"]);
                    }
                }

                if (jObjectSigning["items"] != null)
                {
                    var jArraySigningItems = (JArray)jObjectSigning["items"];

                    foreach (JObject jObjectSigningItem in jArraySigningItems)
                    {
                        project.Signing.Items.Add(new SigningItem()
                        {
                            Selected = JObjectHelper.GetBoolValue(jObjectSigningItem, "selected"),
                            FileName = JObjectHelper.GetStringValue(jObjectSigningItem, "fileName")
                        });
                    }
                }
            }

            // setup
            if (jObject["setup"] != null)
            {
                var jObjectSetup = (JObject)jObject["setup"];

                project.Setup.Enabled = JObjectHelper.GetBoolValue(jObjectSetup, "enabled");

                project.Setup.PluginName = JObjectHelper.GetStringValue(jObjectSetup, "pluginName");

                if (jObjectSetup["pluginParameters"] != null)
                {
                    var pluginInfo = PluginManager.Instance.GetPluginInfoByName(project.Setup.PluginName);
                    if (pluginInfo != null)
                    {
                        var pluginProperties = pluginInfo.Plugin.GetProperties();
                        project.Setup.PluginParameters = GenericPropertySerializer.DeserializeFromJArrayToDictionary(pluginProperties, (JArray)jObjectSetup["pluginParameters"]);
                    }
                }

                if (jObjectSetup["items"] != null)
                {
                    var jArraySetupItems = (JArray)jObjectSetup["items"];

                    foreach (JObject jObjectSetupItem in jArraySetupItems)
                    {
                        project.Setup.Items.Add(new SetupItem()
                        {
                            Selected = JObjectHelper.GetBoolValue(jObjectSetupItem, "selected"),
                            FileName = JObjectHelper.GetStringValue(jObjectSetupItem, "fileName")
                        });
                    }
                }
            }

            return(project);
        }
예제 #9
0
        public static void Save(string fileName, Project project)
        {
            var jObjectProject = new JObject
            {
                ["name"]        = project.Name,
                ["projectPath"] = project.ProjectPath,
                ["outputPath"]  = project.OutputPath
            };

            // obfuscation
            var jObjectObfuscation = new JObject()
            {
                ["enabled"]    = project.Obfuscation.Enabled,
                ["pluginName"] = project.Obfuscation.PluginName
            };
            var pluginInfo = PluginManager.Instance.GetPluginInfoByName(project.Obfuscation.PluginName);

            if (pluginInfo != null)
            {
                var pluginProperties = pluginInfo.Plugin.GetProperties();
                jObjectObfuscation["pluginParameters"] = GenericPropertySerializer.SerializeFromDictionaryToJArray(pluginProperties, project.Obfuscation.PluginParameters);
            }

            var jArrayObfuscationItems = new JArray();

            foreach (var obfuscationItem in project.Obfuscation.Items)
            {
                jArrayObfuscationItems.Add(new JObject()
                {
                    ["selected"] = obfuscationItem.Selected,
                    ["fileName"] = obfuscationItem.FileName
                });
            }
            jObjectObfuscation["items"] = jArrayObfuscationItems;

            jObjectProject["obfuscation"] = jObjectObfuscation;

            // signing
            var jObjectSigning = new JObject()
            {
                ["enabled"]    = project.Signing.Enabled,
                ["pluginName"] = project.Signing.PluginName
            };

            pluginInfo = PluginManager.Instance.GetPluginInfoByName(project.Signing.PluginName);
            if (pluginInfo != null)
            {
                var pluginProperties = pluginInfo.Plugin.GetProperties();
                jObjectSigning["pluginParameters"] = GenericPropertySerializer.SerializeFromDictionaryToJArray(pluginProperties, project.Signing.PluginParameters);
            }

            var jArraySigningItems = new JArray();

            foreach (var signinItem in project.Signing.Items)
            {
                jArraySigningItems.Add(new JObject()
                {
                    ["selected"] = signinItem.Selected,
                    ["fileName"] = signinItem.FileName
                });
            }
            jObjectSigning["items"] = jArraySigningItems;

            jObjectProject["signing"] = jObjectSigning;

            // setup
            var jObjectSetup = new JObject()
            {
                ["enabled"]    = project.Setup.Enabled,
                ["pluginName"] = project.Setup.PluginName
            };

            pluginInfo = PluginManager.Instance.GetPluginInfoByName(project.Setup.PluginName);
            if (pluginInfo != null)
            {
                var pluginProperties = pluginInfo.Plugin.GetProperties();
                jObjectSetup["pluginParameters"] = GenericPropertySerializer.SerializeFromDictionaryToJArray(pluginProperties, project.Signing.PluginParameters);
            }

            var jArraySetupItems = new JArray();

            foreach (var signinItem in project.Signing.Items)
            {
                jArraySetupItems.Add(new JObject()
                {
                    ["selected"] = signinItem.Selected,
                    ["fileName"] = signinItem.FileName
                });
            }
            jObjectSetup["items"] = jArraySetupItems;

            jObjectProject["setup"] = jObjectSetup;

            // write all into output file
            File.WriteAllText(fileName, jObjectProject.ToString(), Encoding.UTF8);
        }