private static bool HasCast(Type type, Type from, Type to, out MethodInfo op)
{
#if WINRT
System.Collections.Generic.List <MethodInfo> list = new System.Collections.Generic.List <MethodInfo>();
foreach (var item in type.GetRuntimeMethods())
{
if (item.IsStatic)
{
list.Add(item);
}
}
MethodInfo[] found = list.ToArray();
#else
const BindingFlags flags = BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic;
MethodInfo[] found = type.GetMethods(flags);
#endif
for (int i = 0; i < found.Length; i++)
{
MethodInfo m = found[i];
if ((m.Name != "op_Implicit" && m.Name != "op_Explicit") || m.ReturnType != to)
{
continue;
}
ParameterInfo[] paramTypes = m.GetParameters();
if (paramTypes.Length == 1 && paramTypes[0].ParameterType == from)
{
op = m;
return(true);
}
}
op = null;
return(false);
}