public static DynamixSettings LoadOptions(dyndnsServices dyndnsServices = null)
        {
            DynamixSettings settings = new DynamixSettings();

            try
            {
                if (File.Exists(settingsFile))
                {
                    using (Stream stream = File.Open(settingsFile, FileMode.Open))
                    {
                        settings = (DynamixSettings)bformatter.Deserialize(stream);
                    }
                    settings.Password = GenericHelper.DecodeFrom64(settings.Password);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }

            if (dyndnsServices != null)
            {
                if (settings.Hosts.Any())
                {
                    dyndnsServices.hostsBoxDynamix.Items.Clear();
                    dyndnsServices.hostsBoxDynamix.Items.AddRange(settings.Hosts.Select(c => c).ToArray());
                }
                dyndnsServices.enableDynamixCB.Checked  = settings.Enabled;
                dyndnsServices.dynamix_user_key_TB.Text = settings.Password;
            }

            return(settings);
        }
        public static NoIPDNSSettings LoadOptions(dyndnsServices dyndnsServices = null)
        {
            NoIPDNSSettings settings = new NoIPDNSSettings();

            try
            {
                if (File.Exists(settingsFile))
                {
                    using (Stream stream = File.Open(settingsFile, FileMode.Open))
                    {
                        settings = (NoIPDNSSettings)bformatter.Deserialize(stream);
                    }
                    settings.Password = GenericHelper.DecodeFrom64(settings.Password);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }

            if (dyndnsServices != null)
            {
                dyndnsServices.noIPPass.Text       = settings.Password;
                dyndnsServices.noIPPassVerify.Text = settings.Password;
                dyndnsServices.noIPEnabled.Checked = settings.Enabled;
                dyndnsServices.noIPHosts.Items.Clear();
                if (settings.Hosts.Any())
                {
                    dyndnsServices.noIPHosts.Items.AddRange(settings.Hosts.ToArray());
                }
                dyndnsServices.noIPLogin.Text = settings.Login;
            }

            return(settings);
        }
        public static XPertDNSSettings LoadOptions(dyndnsServices dyndnsServices = null)
        {
            XPertDNSSettings settings = new XPertDNSSettings();

            try
            {
                if (File.Exists(settingsFile))
                {
                    using (Stream stream = File.Open(settingsFile, FileMode.Open))
                    {
                        settings = (XPertDNSSettings)bformatter.Deserialize(stream);
                    }
                    settings.Password = GenericHelper.DecodeFrom64(settings.Password);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }

            if (dyndnsServices != null)
            {
                dyndnsServices.XPertDNSPass.Text        = settings.Password;
                dyndnsServices.XPertDNSConfirmPass.Text = settings.Password;
                dyndnsServices.xpertEnable.Checked      = settings.Enabled;
                dyndnsServices.dynIDsXPertDNS.Items.Clear();
                if (settings.Hosts.Any())
                {
                    dyndnsServices.dynIDsXPertDNS.Items.AddRange(settings.Hosts.ToArray());
                }
                dyndnsServices.login4XPertDNS.Text = settings.Login;
            }

            return(settings);
        }
        public static string SaveOptions(NoIPDNSSettings settings, dyndnsServices dyndnsServices = null)
        {
            int    errors       = 0;
            string errorMessage = string.Empty;

            if (dyndnsServices != null && settings.Enabled)
            {
                // Perform validation
                if (string.IsNullOrEmpty(dyndnsServices.noIPLogin.Text))
                {
                    errors++;
                    errorMessage += "You must provide your " + serviceName + " login email address!" + Environment.NewLine;
                }
                else
                {
                    if (!GenericHelper.IsValidEmail(dyndnsServices.noIPLogin.Text))
                    {
                        errors++;
                        errorMessage += "You must provide a valid " + serviceName + " login email address!" + Environment.NewLine;
                    }
                }

                if (dyndnsServices.noIPPass.Text != dyndnsServices.noIPPassVerify.Text)
                {
                    errors++;
                    errorMessage += "The " + serviceName + " passwords do not match!" + Environment.NewLine;
                }
                else
                {
                    if (!string.IsNullOrEmpty(dyndnsServices.noIPPass.Text) && !string.IsNullOrEmpty(dyndnsServices.noIPPassVerify.Text))
                    {
                        settings.Password = dyndnsServices.noIPPass.Text;
                    }
                    else
                    {
                        errors++;
                        errorMessage += "You must provide your " + serviceName + " password and confirm the password." + Environment.NewLine;
                    }
                }

                if (dyndnsServices.noIPHosts.Items.Count <= 0)
                {
                    errors++;
                    errorMessage += "There are no " + serviceName + " hosts to save!" + Environment.NewLine;
                }
            }

            if (errors == 0)
            {
                //serialize
                settings.Password = GenericHelper.EncodeTo64(settings.Password);
                using (Stream stream = File.Open(settingsFile, FileMode.Create))
                {
                    bformatter.Serialize(stream, settings);
                }
            }

            return(errorMessage);
        }