public static Type GuessType(Type type, Type propertyType)
{
Type otherend = type;
if (otherend == null)
{
// naive guessing of type if not specified
if (propertyType.IsGenericType)
{
Type[] arguments = propertyType.GetGenericArguments();
if (arguments.Length == 1)
{
otherend = arguments[0];
}
}
}
return otherend;
}
}