public bool IsSpecialCollectionType(Type type)
{
if (_isSpecialCollectionCache.ContainsKey(type))
{
return _isSpecialCollectionCache[type];
}
// Check all sub types as well (a type might be deriving from IEnumerable)
var baseType = type;
while (baseType != null)
{
if (IsSpecificTypeSpecialCollection(baseType))
{
// Note: this is not a bug, we need to add type to the collection
_isSpecialCollectionCache[type] = true;
return true;
}
baseType = baseType.GetBaseTypeEx();
}
var implementedInterfaces = type.GetInterfacesEx();
foreach (var implementedInterface in implementedInterfaces)
{
if (IsSpecificTypeSpecialCollection(implementedInterface))
{
// Note: this is not a bug, we need to add type to the collection
_isSpecialCollectionCache[type] = true;
return true;
}
}
_isSpecialCollectionCache[type] = false;
return false;
}