本文整理汇总了C#中JsonValue.Equals方法的典型用法代码示例。如果您正苦于以下问题:C# JsonValue.Equals方法的具体用法?C# JsonValue.Equals怎么用?C# JsonValue.Equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JsonValue
的用法示例。
在下文中一共展示了JsonValue.Equals方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: assertJsonValueNotEqualComparison
private void assertJsonValueNotEqualComparison(JsonValue value)
{
Assert.IsFalse(value.Equals(null));
if (!(value is JsonBool)) Assert.IsFalse(value.Equals(new JsonBool(true)));
if (!(value is JsonString)) Assert.IsFalse(value.Equals(new JsonString("abc")));
if (!(value is JsonNumber)) Assert.IsFalse(value.Equals(JsonNumber.Create(47)));
if (!(value is JsonList)) Assert.IsFalse(value.Equals(new JsonList()));
if (!(value is JsonDict)) Assert.IsFalse(value.Equals(new JsonDict()));
}
示例2: assertValueEqual
private void assertValueEqual(JsonValue val1, JsonValue val2)
{
Assert.IsTrue(val1.Equals(val2));
}
示例3: assertValueNotEqual
private void assertValueNotEqual(JsonValue val1, JsonValue val2)
{
Assert.IsFalse(val1.Equals(val2));
}
示例4: Equality
public void Equality()
{
// object
JsonValue one = new JsonValue { {"one", 1}, {"two", 2} };
JsonValue two = new JsonValue { {"one", 1}, {"two", 2} };
JsonValue three = new JsonValue { {"one", 1}, {"two", 2}, {"three", 3} };
Assert.That(one.Equals(two), Is.True);
Assert.That(one.Equals(three), Is.False);
// array
one = new JsonValue { 1, 2, 3 };
two = new JsonValue { 1, 2, 3 };
three = new JsonValue { 3, 2, 1 };
Assert.That(one.Equals(two), Is.True);
Assert.That(one.Equals(three), Is.False);
// string
one = "one";
two = "one";
three = "two";
Assert.That(one.Equals(two), Is.True);
Assert.That(one.Equals(three), Is.False);
// bool
one = true;
two = true;
three = false;
Assert.That(one.Equals(two), Is.True);
Assert.That(one.Equals(three), Is.False);
// int
one = 1;
two = 1;
three = 2;
Assert.That(one.Equals(two), Is.True);
Assert.That(one.Equals(three), Is.False);
// float
one = 1f;
two = 1f;
three = 2f;
Assert.That(one.Equals(two), Is.True);
Assert.That(one.Equals(three), Is.False);
}