Exemplo n.º 1
0
        /// <summary>
        /// Add the Local State Preferences from the app.config file
        /// </summary>
        private void AddLocalStatePreferences()
        {
            string name     = "";
            object objValue = new object();

            try
            {
                var preferenceList = Chrome.LocalStatePreferences;


                if (preferenceList != null && preferenceList.Contains(","))
                {
                    var list = preferenceList.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);

                    foreach (string preference in list)
                    {
                        string[] setting = preference.Split(new string[] { "=", "|" }, StringSplitOptions.RemoveEmptyEntries);
                        name = setting[0];
                        Type valueType = Type.GetType(setting[2]);
                        objValue = Convert.ChangeType(setting[1], valueType);
                        Options.AddLocalStatePreference(name, objValue);
                    }
                }
            }
            catch (Exception ex)
            {
                switch (BaseSettings.DebugLevel)
                {
                case EnumConsoleDebugLevel.Human:
                    Console.Out.WriteLine("Unable to add the local state settings specified in the config file");
                    Console.Out.WriteLine("Setting: {0} | Value: {1}", name, objValue.ToString());
                    break;

                case EnumConsoleDebugLevel.NotSpecified:
                case EnumConsoleDebugLevel.Message:
                    Console.Out.WriteLine(ex.Message);
                    break;

                case EnumConsoleDebugLevel.StackTrace:
                    Console.Out.WriteLine(ex.Message);
                    Console.Out.WriteLine(ex.StackTrace);
                    break;
                }
            }
        }