private static bool IsIterableCollection()

in sdk/Sdk/FunctionMetadataGenerator.cs [581:632]


        private static bool IsIterableCollection(TypeReference type, out DataType dataType)
        {
            // Array and not byte array
            bool isArray = type.IsArray && !string.Equals(type.FullName, Constants.ByteArrayType, StringComparison.Ordinal);
            if (isArray)
            {
                if (type is TypeSpecification typeSpecification)
                {
                    dataType = GetDataTypeFromType(typeSpecification.ElementType.FullName);
                    return true;
                }
            }

            bool isMappingEnumerable = IsOrDerivedFrom(type, Constants.IEnumerableOfKeyValuePair)
                || IsOrDerivedFrom(type, Constants.LookupGenericType)
                || IsOrDerivedFrom(type, Constants.DictionaryGenericType);
            if (isMappingEnumerable)
            {
                dataType = DataType.Undefined;
                return false;
            }

            // IEnumerable and not string or dictionary
            bool isEnumerableOfT = IsOrDerivedFrom(type, Constants.IEnumerableOfT);
            bool isEnumerableCollection =
                !IsStringType(type.FullName)
                && (IsOrDerivedFrom(type, Constants.IEnumerableType)
                    || IsOrDerivedFrom(type, Constants.IEnumerableGenericType)
                    || isEnumerableOfT);
            if (isEnumerableCollection)
            {
                dataType = DataType.Undefined;
                if (IsOrDerivedFrom(type, Constants.IEnumerableOfStringType))
                {
                    dataType = DataType.String;
                }
                else if (IsOrDerivedFrom(type, Constants.IEnumerableOfBinaryType))
                {
                    dataType = DataType.Binary;
                }
                else if (isEnumerableOfT)
                {
                    // Find real type that "T" in IEnumerable<T> resolves to
                    string typeName = ResolveIEnumerableOfTType(type, new Dictionary<string, string>()) ?? string.Empty;
                    dataType = GetDataTypeFromType(typeName);
                }
                return true;
            }

            dataType = DataType.Undefined;
            return false;
        }