public EnumerationData(Type itemType) { EnumerableType = typeof(IEnumerable <>).MakeGenericType(itemType); EnumeratorType = typeof(IEnumerator <>).MakeGenericType(itemType); GetEnumerator = EnumerableType.GetMethod("GetEnumerator", new Type[0]); Current = EnumeratorType.GetProperty("Current"); }
private GenericCollectionInfo(Type collectionType, Type elementType, ConstructorInfo constructor) { CollectionType = collectionType; ElementType = elementType; Constructor = constructor; _countPropertyLazy = new Lazy <MethodInfo>(() => CollectionType.GetProperty("Count").GetMethod); _addMethodLazy = new Lazy <MethodInfo>(() => CollectionType.GetMethod("Add", new Type[] { elementType })); _getEnumeratorMethodLazy = new Lazy <MethodInfo>(() => CollectionType.GetMethod("GetEnumerator")); _enumeratorMoveNextMethodLazy = new Lazy <MethodInfo>(() => EnumeratorType.GetMethod("MoveNext")); _enumeratorCurrentPropertyLazy = new Lazy <MethodInfo>(() => EnumeratorType.GetProperty("Current").GetMethod); }