mirror of
https://github.com/codewriter-packages/Tri-Inspector.git
synced 2025-01-22 08:18:49 -05:00
Fix value comparer
This commit is contained in:
parent
87972df66b
commit
b02c4aa388
@ -407,6 +407,21 @@ namespace TriInspector
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool AreValuesEqual(Type type, object a, object b)
|
||||
{
|
||||
if (type == typeof(string))
|
||||
{
|
||||
return string.Equals((string) a, (string) b);
|
||||
}
|
||||
|
||||
if (type.IsValueType || type == typeof(string))
|
||||
{
|
||||
return a.Equals(b);
|
||||
}
|
||||
|
||||
return ReferenceEquals(a, b);
|
||||
}
|
||||
|
||||
private static void SetValueRecursive(TriProperty property, object value, int targetIndex)
|
||||
{
|
||||
// for value types we must recursively set all parent objects
|
||||
@ -480,11 +495,7 @@ namespace TriInspector
|
||||
for (var i = 1; i < property.PropertyTree.TargetObjects.Length; i++)
|
||||
{
|
||||
var otherValue = property.GetValue(i);
|
||||
var otherValueIsSame = property.FieldType.IsValueType
|
||||
? otherValue.Equals(newValue)
|
||||
: ReferenceEquals(otherValue, newValue);
|
||||
|
||||
if (!otherValueIsSame)
|
||||
if (!AreValuesEqual(property.FieldType, otherValue, newValue))
|
||||
{
|
||||
isMixed = true;
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user