示例#1
0
        public bool Check(Type type)
        {
            if (ContainsGenericParametersChecker.Check(type))
            {
                Type enumerable = GenericGenerator.Generate(typeof(IEnumerable <>), GenericParametersProvider.ProvideGenericTypes(type).FirstOrDefault());

                return(enumerable.IsAssignableFrom(type));
            }

            return(false);
        }
        public object GenerateEnumerable(Type enumerableType)
        {
            IEnumerable <Type> genericTypes = GenericParametersProvider.ProvideGenericTypes(enumerableType);

            Type enumerableOf = genericTypes
                                .First();

            Type list = GenericTypeGenerator.Generate(typeof(List <>), enumerableOf);

            return(Activator.CreateInstance(list));
        }