src/Mimp.SeeSharper.Reflection/TypeExtensions.cs
/// <summary>
/// Return the value type of <see cref="ICollection"/>.
/// </summary>
/// <param name="type"></param>
/// <returns></returns>
/// <exception cref="ArgumentNullException"></exception>
/// <exception cref="InvalidOperationException">If type isn't <see cref="ICollection"/>.</exception>
Return the value type of .
Return the value type of .
public static Type? GetICollectionValueType(this Type type)
        {
            try
            {
                var types = type.GetGenericArguments(typeof(ICollection<>));
                return types.Any() ? types.First() : null;
            }
            catch
            {
                if (type.IsICollection())
                    return typeof(object);
                throw;
            }
        }
public static Type ? GetICollectionValueType ( this Type type ) { try { var types = type . GetGenericArguments ( typeof ( ICollection < > ) ) ; return types . Any ( ) ? types . First ( ) : null ; } catch { if ( type . IsICollection ( ) ) return typeof ( object ) ; throw ; } }
Return the value type of .
Return the value type of .
None
None
If type isn't .
If type isn ' t .
Type
this
type
None