Antmicro.Migrant.Utilities.SwapList.GenericIsMatch C# (CSharp) Метод

GenericIsMatch() приватный статический Метод

private static GenericIsMatch ( Type candidate, Type value ) : bool
candidate System.Type
value System.Type
Результат bool
        private static bool GenericIsMatch(Type candidate, Type value)
        {
            if(candidate.IsInterface)
            {
                var interfaces = value.GetInterfaces();
                if(Array.IndexOf(interfaces, candidate) != -1)
                {
                    return true;
                }
            }
            while(value != null && value != typeof(object))
            {
                if(value == candidate)
                {
                    return true;
                }
                value = value.BaseType;
                if(!value.IsGenericType)
                {
                    break;
                }
                value = value.GetGenericTypeDefinition();
            }
            return false;
        }