/// <summary>
 /// Select a item from an enum
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <returns></returns>
 public static async Task <T> Select <T>() where T : Enum
 {
     return((
                await InputSelection
                .FromEnum <T>()
                .RequestInput()
                ).First());
 }
 /// <summary>
 /// Select a items from an enum
 /// </summary>
 /// <param name="max">max allowed selections</param>
 /// <returns></returns>
 public static Task <IEnumerable <T> > Select <T>(int max) where T : Enum
 {
     return(
         InputSelection
         .FromEnum <T>()
         .SetMaxSelected(max)
         .RequestInput()
         );
 }
        public TestFormClass()
        {
            ValidatorProvider.Global.Register(REQUIRED, ValidatorCollection
                                              .Create <string>().Add(s => (s.Length > 0, "Can't be empty")));
            ValidatorProvider.Global.Register(AGE_INTERVAL, ValidatorCollection
                                              .Create <uint>()
                                              .Add(n => (n >= 13, "Age must be older than 13"))
                                              .Add(n => (n <= 150, "Age must be younger then 150"))
                                              );

            StringConverterProvider.Global.Register(new UriConverter());

            ComponentsProvider.Global.Register(WORK_TITLES_COMPONENT,
                                               InputSelection.FromEnum <WorkTitles>());

            ComponentsProvider.Global.Register(URL_COMPONENT,
                                               InputText.Create <Uri>("Url"));
        }
        private static async void StartDemo()
        {
            const string NAME = "#BUFFER_SELECTION123#";

            ConsoleBuffer.MemoriseBufferPosition(NAME);

            Console.WriteLine("Select 1 option");
            var selection = InputSelection.From <TestClass>()
                            .AddOption(new TestClass {
                Name = "option1"
            })
                            .AddOption(new TestClass {
                Name = "option2"
            })
                            .AddOption(new TestClass {
                Name = "option3"
            })
                            .AddOption(new TestClass {
                Name = "option4"
            });

            var result1 = await selection.RequestInput();

            Console.WriteLine($"Selected => {result1.First()}");
            ConsoleI.AwaitContinue();
            ConsoleBuffer.ClearBufferFrom(NAME);

            Console.WriteLine("Select 1 to 5 options");
            var selection2 = InputSelection.From <TestClass>()
                             .SetMaxSelected(5)
                             .AddOption(new TestClass {
                Name = "option1"
            })
                             .AddOption(new TestClass {
                Name = "option2"
            })
                             .AddOption(new TestClass {
                Name = "option3"
            })
                             .AddOption(new TestClass {
                Name = "option4"
            })
                             .AddOption(new TestClass {
                Name = "option5"
            })
                             .AddOption(new TestClass {
                Name = "option6"
            })
                             .AddOption(new TestClass {
                Name = "option7"
            })
                             .AddOption(new TestClass {
                Name = "option8"
            })
                             .AddOption(new TestClass {
                Name = "option9"
            })
                             .AddOption(new TestClass {
                Name = "option10"
            })
                             .AddOption(new TestClass {
                Name = "option11"
            });

            var result2 = await selection2.RequestInput();

            foreach (var r in result2)
            {
                Console.WriteLine($"Selected => {r}");
            }
            ConsoleI.AwaitContinue();
            ConsoleBuffer.ClearBufferFrom(NAME);

            Console.WriteLine("Also works with ENUM");
            var result3 = await InputSelection
                          .FromEnum <EnumTest>()
                          .RequestInput();

            foreach (var r in result3)
            {
                Console.WriteLine($"Selected => {(int)r}");
            }
            ConsoleI.AwaitContinue();
            ConsoleBuffer.ClearBufferFrom(NAME);
        }