24 lines
572 B
C#
24 lines
572 B
C#
using System;
|
|
|
|
internal static class BSValueUtility
|
|
{
|
|
public static bool Equals(BSValue a, BSValue b)
|
|
{
|
|
a = a.Normalize();
|
|
b = b.Normalize();
|
|
if (a.Kind != b.Kind)
|
|
{
|
|
return false;
|
|
}
|
|
return a.Kind switch
|
|
{
|
|
BSValueKind.Number => Math.Abs(a.Number - b.Number) <= 0.0001,
|
|
BSValueKind.Text => string.Equals(a.Text ?? string.Empty, b.Text ?? string.Empty, StringComparison.Ordinal),
|
|
BSValueKind.Bool => a.Bool == b.Bool,
|
|
BSValueKind.Player => a.PlayerId == b.PlayerId,
|
|
BSValueKind.Group => a.GroupId == b.GroupId,
|
|
_ => true,
|
|
};
|
|
}
|
|
}
|