Пример #1
0
        static MenuState ShowKey()
        {
            ShowSeparator();
            var meta = currentKey.GetMetadata();

            Console.ForegroundColor = ConsoleColor.White;
            Console.WriteLine("Key {0} in section {1}", currentKey, currentSection);

            Console.Write("  Description: ");
            Console.ResetColor();
            string[] newlineSeparator = new[] { "\r\n" };
            string[] descriptionLines = meta.Description.Split(newlineSeparator, StringSplitOptions.RemoveEmptyEntries);
            Console.WriteLine(descriptionLines[0]);
            for (int i = 1; i < descriptionLines.Length; i++)
            {
                Console.WriteLine("    " + descriptionLines[i]);
            }

            Console.ForegroundColor = ConsoleColor.White;
            Console.Write("  Type: ");
            Console.ResetColor();
            Console.WriteLine(meta.ValueType.Name);

            Console.ForegroundColor = ConsoleColor.White;
            Console.Write("  Default value: ");
            Console.ResetColor();
            Console.WriteLine(meta.DefaultValue);

            Console.ForegroundColor = ConsoleColor.White;
            Console.Write("  Current value: ");
            Console.ResetColor();
            Console.WriteLine(currentKey.GetString());

            Console.ForegroundColor = ConsoleColor.White;
            Console.Write("  New value: ");
            Console.ResetColor();

            while (true)
            {
                try {
                    currentKey.SetValue(Console.ReadLine());
                    break;
                } catch (FormatException ex) {
                    Console.WriteLine(ex.Message);
                }
            }

            return(MenuState.KeyList);
        }