Esempio n. 1
0
        private static bool TryGetTypeToGenerate(this Type type, IDataConverter converter, out Type t)
        {
            t = type;
            if (type.IsValueType ||
                type == typeof(void) ||
                type.IsEnum ||
                type == typeof(object) ||
                type == typeof(string) ||
                !type.IsBrowsable() ||
                (converter?.IsDefined(type) ?? false))
            {
                return(false);
            }

            // Manage out and ref
            if (type.IsByRef)
            {
                t = type.GetElementType();
                return(t.ShouldGenerateR6(converter));
            }

            // Manage array
            if (type.IsArray)
            {
                t = type.GetElementType();
                return(t.ShouldGenerateR6(converter));
            }

            // Manage IEnumerable<>
            if (type.GetInterfaces().Any(p => p.IsGenericType && p.GetGenericTypeDefinition() == typeof(IEnumerable <>)))
            {
                t = type.GetGenericArguments()[0];
                return(t.ShouldGenerateR6(converter));
            }

            return(!type.IsGenericType && // Not yet supported
                   !type.InheritsFrom(typeof(IEnumerable)));
        }