Esempio n. 1
0
        private static void TryIenumImp()
        {
            var collection = new string[] { "Eslam", "ali", "mai", "Blablablablabla" };
            var config     = new EnumeratorConfig {
                MinLength = 4, MaxLength = 55, StartWithCapitalLetter = true
            };
            var enumerator = new CustomStringEnumerator(collection, config);

            foreach (var s in enumerator)
            {
                Console.WriteLine(s);
            }
        }
        /// <summary> Constructor </summary>
        /// <exception cref="System.ArgumentNullException">If a collection is null</exception>
        /// <exception cref="System.ArgumentNullException">If a config is null</exception>
        public CustomStringEnumerator(IEnumerable <string> collection, EnumeratorConfig config)
        {
            if (config.StartWithCapitalLetter == true)
            {
                _listOfString = collection.Where(s =>
                                                 s.Length >= config.MinLength && s.Length <= config.MaxLength && char.IsUpper(s[0]));
            }

            else
            {
                _listOfString = collection.Where(s =>
                                                 s.Length >= config.MinLength && s.Length <= config.MaxLength && char.IsLower(s[0]));
            }
        }