Is Generic Container - CSharp System.Reflection

CSharp examples for System.Reflection:Modifier

Description

Is Generic Container

Demo Code


using System.Threading.Tasks;
using System.Text;
using System.Runtime.Serialization;
using System.Runtime.CompilerServices;
using System.Reflection.Emit;
using System.Reflection;
using System.Linq;
using System.IO;/*from w  w w. jav  a  2s .c om*/
using System.Globalization;
using System.Collections.Generic;
using System;

public class Main{
        public static bool IsGenericContainer(this Type forType, Type containerType)
        {
            return forType.IsInterface() && forType.IsGenericType() && forType.GetGenericTypeDefinition() == containerType;
        }
        public static bool IsInterface(this Type type)
        {
            var info = type.GetTypeInfo();

            return info.IsInterface;
        }
        public static bool IsGenericType(this Type type)
        {
            var info = type.GetTypeInfo();

            return info.IsGenericType;
        }
}

Related Tutorials