Antmicro.Migrant.Utilities.SwapList.GenericIsMatch C# (CSharp) Method

GenericIsMatch() private static method

private static GenericIsMatch ( Type candidate, Type value ) : bool
candidate System.Type
value System.Type
return 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;
        }