public static Type FindSurrogateSourceType(Type type)
{
var flags = BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic;
foreach (var m in type.GetMethods(flags))
{
var parameters = m.GetParameters();
if (parameters.Length == 1 && m.ReturnType.Name != "Void" && m.ReturnType != type)
{
if (Attribute.GetCustomAttribute(m, typeof(ProtoBuf.ProtoConverterAttribute)) != null)
return m.ReturnType;
if (m.Name == "op_Implicit" || m.Name == "op_Explicit")
return m.ReturnType;
}
}
return null;
}
}