You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Connected.Framework/Connected.Interop/TypeComparer.cs

29 lines
677 B

namespace Connected.Interop
{
public static class TypeComparer
{
public static bool Compare(object? left, object? right)
{
if (left is null && right is null)
return true;
if (left is null && right is not null)
return false;
if (left is not null && right is null)
return false;
if (!TypeConversion.TryConvert(left, out string? leftString))
return false;
if (!TypeConversion.TryConvert(right, out string? rightString))
return false;
if (Guid.TryParse(leftString, out Guid lg) && Guid.TryParse(rightString, out Guid rg))
return lg == rg;
return string.Equals(leftString, rightString, StringComparison.Ordinal);
}
}
}