internal static ExtendedType?GetInnerListType( ExtendedType type, TypeCache cache) { if (IsDictionary(type.Type)) { IExtendedType key = type.TypeArguments[0]; IExtendedType value = type.TypeArguments[1]; Type itemType = typeof(KeyValuePair <,>).MakeGenericType(key.Type, value.Type); return(cache.GetOrCreateType(itemType, () => { return new ExtendedType( itemType, ExtendedTypeKind.Runtime, new[] { (ExtendedType)key, (ExtendedType)value }, isNullable: false); })); } if (IsSupportedCollectionInterface(type.Type)) { return(type.TypeArguments[0]); } if (type.IsInterface && type.Definition == typeof(IEnumerable <>)) { return(type.TypeArguments[0]); } foreach (Type interfaceType in type.Type.GetInterfaces()) { if (IsSupportedCollectionInterface(interfaceType)) { Type elementType = interfaceType.GetGenericArguments()[0]; if (type.TypeArguments.Count == 1 && type.TypeArguments[0].Type == elementType) { return(type.TypeArguments[0]); } return(SystemType.FromType(elementType, cache)); } } return(null); }
private static ExtendedType FromTypeInternal(Type type, TypeCache cache) => Helper.IsSchemaType(type) ? SchemaType.FromType(type, cache) : SystemType.FromType(type, cache);