private static int FindMostSpecificType(Type c1, Type c2, Type t)
{
if (c1 == c2)
{
return(0);
}
if (c1 == t)
{
return(1);
}
if (c2 == t)
{
return(2);
}
if (c1.IsByRef || c2.IsByRef)
{
if (c1.IsByRef && c2.IsByRef)
{
c1 = c1.GetElementType();
c2 = c2.GetElementType();
}
else if (c1.IsByRef)
{
if (c1.GetElementType() == c2)
{
return(2);
}
c1 = c1.GetElementType();
}
else
{
if (c2.GetElementType() == c1)
{
return(1);
}
c2 = c2.GetElementType();
}
}
bool flag1;
bool flag2;
if (c1.IsPrimitive && c2.IsPrimitive)
{
flag1 = DefaultBinder.CanConvertPrimitive((RuntimeType)c2, (RuntimeType)c1);
flag2 = DefaultBinder.CanConvertPrimitive((RuntimeType)c1, (RuntimeType)c2);
}
else
{
flag1 = c1.IsAssignableFrom(c2);
flag2 = c2.IsAssignableFrom(c1);
}
if (flag1 == flag2)
{
return(0);
}
return(flag1 ? 2 : 1);
}