18 using System.Collections.Generic;
20 namespace Deveel.Data.Linq {
23 Type ienum = FindIEnumerable(seqType);
28 return ienum.GetGenericArguments()[0];
32 if (seqType == null || seqType == typeof(
string))
36 return typeof(IEnumerable<>).MakeGenericType(seqType.GetElementType());
38 if (seqType.IsGenericType) {
39 foreach (Type arg
in seqType.GetGenericArguments()) {
40 Type ienum = typeof(IEnumerable<>).MakeGenericType(arg);
41 if (ienum.IsAssignableFrom(seqType)) {
47 Type[] ifaces = seqType.GetInterfaces();
49 if (ifaces.Length > 0) {
50 foreach (Type iface
in ifaces) {
51 Type ienum = FindIEnumerable(iface);
52 if (ienum != null)
return ienum;
56 if (seqType.BaseType != null && seqType.BaseType != typeof(
object)) {
57 return FindIEnumerable(seqType.BaseType);
static Type GetElementType(Type seqType)
static Type FindIEnumerable(Type seqType)