コード例 #1
0
        public void EditPatterns()
        {
            var patterns = DictionaryExtensions.DeserializeFromFile(@"patterns.xml");

            if (patterns == null)
            {
                Console.WriteLine("\nSorry, no patterns");
            }

            ShowPatterns(patterns);

            Console.WriteLine("\nPlease, input number pattern for edit");

            int[] patternNumbers = Enumerable.Range(1, patterns.Count).ToArray();
            int   number         = InputHelper.ValidateTwoDigitNumberInput(Console.ReadLine(), patternNumbers);
            var   pattern        = patterns.ToList()[number - 1];

            Console.WriteLine("\nPlease, input new value for pattern");
            Console.WriteLine("\n" + pattern.Key);

            char value = InputHelper.ValidateLetterOrDigitInput(Console.ReadKey());

            patterns[pattern.Key] = value;

            patterns.SerializeToFile(@"patterns.xml");

            Console.WriteLine("\n\nСhanges saved successfully");
        }
コード例 #2
0
        public void ShowPatterns()
        {
            var patterns = DictionaryExtensions.DeserializeFromFile(@"patterns.xml");

            if (patterns == null)
            {
                Console.WriteLine("\nSorry, no patterns");
            }

            ShowPatterns(patterns);
        }
コード例 #3
0
        public void UpdatePatterns(List <StringBuilder> contents)
        {
            Dictionary <string, char> patterns = DictionaryExtensions.DeserializeFromFile(@"patterns.xml");

            if (patterns == null)
            {
                patterns = new Dictionary <string, char>();
            }

            foreach (var pattern in contents)
            {
                if (!patterns.ContainsKey(pattern.ToString()))
                {
                    patterns.Add(pattern.ToString(), '?');
                    Console.WriteLine("\n" + pattern);
                }
            }

            patterns.SerializeToFile(@"patterns.xml");
        }