コード例 #1
0
        private static void AllowAddingCustomDelimiter(Delimiters delimiters)
        {
            Console.WriteLine("Press Y to add a custom delimiter or any character to skip.");

            if (char.TryParse(Console.ReadLine(), out char prompt) && (prompt == 'Y' || prompt == 'y'))
            {
                TryGetDelimiterInput(delimiters);

                while (true)
                {
                    Console.WriteLine("Press M to add another delimiter or any character to skip.");

                    if (char.TryParse(Console.ReadLine(), out char moreDelimiterPrompt))
                    {
                        if (moreDelimiterPrompt == 'M' || moreDelimiterPrompt == 'm')
                        {
                            TryGetDelimiterInput(delimiters);
                        }
                        else
                        {
                            break;
                        }
                    }
                    else
                    {
                        Console.WriteLine("Invalid Input.");
                    }
                }
            }
        }
コード例 #2
0
        private static void TryGetDelimiterInput(Delimiters delimiters)
        {
            Console.WriteLine("Enter a single character custom delimiter: ");

            if (char.TryParse(Console.ReadLine(), out char input))
            {
                var customDelimiter = new Delimiter(input, true);
                delimiters.Add(customDelimiter);
            }
            else
            {
                Console.WriteLine("Invalid Input.");
                TryGetDelimiterInput(delimiters);
            }
        }
コード例 #3
0
        private static Delimiters GetDelimiters()
        {
            var defaultDelimiters = new List <Delimiter>()
            {
                new Delimiter(',', true),
                new Delimiter('\n', true)
            };

            if (altDelimiter != null)
            {
                defaultDelimiters.Add(new Delimiter(altDelimiter.Value, true));
            }

            var delimiters = new Delimiters(defaultDelimiters);

            AllowAddingCustomDelimiter(delimiters);

            return(delimiters);
        }