当前位置: 首页>>代码示例>>C#>>正文


C# JArray.DeepEquals方法代码示例

本文整理汇总了C#中Newtonsoft.Json.Linq.JArray.DeepEquals方法的典型用法代码示例。如果您正苦于以下问题:C# JArray.DeepEquals方法的具体用法?C# JArray.DeepEquals怎么用?C# JArray.DeepEquals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Newtonsoft.Json.Linq.JArray的用法示例。


在下文中一共展示了JArray.DeepEquals方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DoubleDeepEquals

        public void DoubleDeepEquals()
        {
            JArray a =
                new JArray(
                    double.NaN,
                    double.PositiveInfinity,
                    double.NegativeInfinity
                    );

            JArray a2 = (JArray)a.DeepClone();

            Assert.IsTrue(a.DeepEquals(a2));

            double d = 1 + 0.1 + 0.1 + 0.1;

            JValue v1 = new JValue(d);
            JValue v2 = new JValue(1.3);

            Assert.IsTrue(v1.DeepEquals(v2));
        }
开发者ID:rogeralsing,项目名称:Newtonsoft.Json,代码行数:20,代码来源:JTokenTests.cs

示例2: DeepClone

        public void DeepClone()
        {
            JArray a =
                new JArray(
                    5,
                    new JArray(1),
                    new JArray(1, 2),
                    new JArray(1, 2, 3),
                    new JObject(
                        new JProperty("First", new JValue(Encoding.UTF8.GetBytes("Hi"))),
                        new JProperty("Second", 1),
                        new JProperty("Third", null),
                        new JProperty("Fourth", new JConstructor("Date", 12345)),
                        new JProperty("Fifth", double.PositiveInfinity),
                        new JProperty("Sixth", double.NaN)
                        )
                    );

            JArray a2 = (JArray)a.DeepClone();

            StringAssert.AreEqual(@"[
  5,
  [
    1
  ],
  [
    1,
    2
  ],
  [
    1,
    2,
    3
  ],
  {
    ""First"": ""SGk="",
    ""Second"": 1,
    ""Third"": null,
    ""Fourth"": new Date(
      12345
    ),
    ""Fifth"": ""Infinity"",
    ""Sixth"": ""NaN""
  }
]", a2.ToString(Formatting.Indented));

            Assert.IsTrue(a.DeepEquals(a2));
        }
开发者ID:rogeralsing,项目名称:Newtonsoft.Json,代码行数:48,代码来源:JTokenTests.cs

示例3: Clone

        public void Clone()
        {
            JArray a =
                new JArray(
                    5,
                    new JArray(1),
                    new JArray(1, 2),
                    new JArray(1, 2, 3),
                    new JObject(
                        new JProperty("First", new JValue(Encoding.UTF8.GetBytes("Hi"))),
                        new JProperty("Second", 1),
                        new JProperty("Third", null),
                        new JProperty("Fourth", new JConstructor("Date", 12345)),
                        new JProperty("Fifth", double.PositiveInfinity),
                        new JProperty("Sixth", double.NaN)
                        )
                    );

            ICloneable c = a;

            JArray a2 = (JArray)c.Clone();

            Assert.IsTrue(a.DeepEquals(a2));
        }
开发者ID:rogeralsing,项目名称:Newtonsoft.Json,代码行数:24,代码来源:JTokenTests.cs

示例4: DeepClone

    public void DeepClone()
    {
      JArray a =
        new JArray(
          5,
          new JArray(1),
          new JArray(1, 2),
          new JArray(1, 2, 3),
          new JObject(
            new JProperty("First", new JValue(Encoding.UTF8.GetBytes("Hi"))),
            new JProperty("Second", 1),
            new JProperty("Third", null),
            new JProperty("Fourth", new JConstructor("Date", 12345)),
            new JProperty("Fifth", double.PositiveInfinity),
            new JProperty("Sixth", double.NaN)
            )
        );

      JArray a2 = (JArray)a.DeepClone();

      Console.WriteLine(a2.ToString(Formatting.Indented));

      Assert.IsTrue(a.DeepEquals(a2));
    }
开发者ID:cycorey,项目名称:Newtonsoft.Json,代码行数:24,代码来源:JTokenTests.cs


注:本文中的Newtonsoft.Json.Linq.JArray.DeepEquals方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。