Esempio n. 1
0
        private IEnumerable <ICountingStrategy> ForGenericCollection()
        {
            var collection = values as ICollection;

            if (!ReferenceEquals(null, collection))
            {
                yield return(CountingStrategy.ByCountGetter(() => collection.Count));

                yield return(CountingStrategy.ByEnumeratingElements(values));
            }
        }
Esempio n. 2
0
        private IEnumerable <ICountingStrategy> ForNonGenericCollection()
        {
            foreach (Type type in values.GetType().GetInterfaces())
            {
                if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(ICollection <>))
                {
                    yield return(CountingStrategy.ByCountGetter(() => (int)type.GetProperty("Count").GetValue(values, null)));

                    yield return(CountingStrategy.ByEnumeratingElements(values));
                }
            }
        }