public static bool AreEqual (Type type, object x, object y)
{
if (x == null)
return y == null;
if (y == null)
return false;
if (type == null) {
if (x.GetType ().IsValueType || x.GetType () == typeof (string))
return x.Equals (y);
} else if (type.IsValueType) {
return x.Equals (y);
}
return x == y;
}