本文整理汇总了C#中Newtonsoft.Json.Linq.JArray.DeepClone方法的典型用法代码示例。如果您正苦于以下问题:C# JArray.DeepClone方法的具体用法?C# JArray.DeepClone怎么用?C# JArray.DeepClone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Newtonsoft.Json.Linq.JArray
的用法示例。
在下文中一共展示了JArray.DeepClone方法的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));
}
示例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();
Console.WriteLine(a2.ToString(Formatting.Indented));
Assert.IsTrue(a.DeepEquals(a2));
}
示例3: 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));
}
示例4: CreateSwaggerPathForEntity
static JObject CreateSwaggerPathForEntity(IEdmEntitySet entitySet)
{
var keyParameters = new JArray();
foreach (var key in entitySet.EntityType().Key())
{
string format;
string type = GetPrimitiveTypeAndFormat(key.Type.Definition as IEdmPrimitiveType, out format);
keyParameters.Parameter(key.Name, "path", "key: " + key.Name, type, format);
}
return new JObject()
{
{
"get", new JObject()
.Summary("Get entity from " + entitySet.Name + " by key.")
.Description("Returns the entity with the key from " + entitySet.Name)
.Tags(entitySet.Name)
.Parameters((keyParameters.DeepClone() as JArray)
.Parameter("$select", "query", "description", "string")
)
.Responses(new JObject()
.Response("200", "EntitySet " + entitySet.Name, entitySet.EntityType())
.DefaultErrorResponse()
)
},
{
"patch", new JObject()
.Summary("Update entity in EntitySet " + entitySet.Name)
.Description("Update entity in EntitySet " + entitySet.Name)
.Tags(entitySet.Name)
.Parameters((keyParameters.DeepClone() as JArray)
.Parameter(entitySet.EntityType().Name, "body", "The entity to patch",
entitySet.EntityType())
)
.Responses(new JObject()
.Response("204", "Empty response")
.DefaultErrorResponse()
)
},
{
"delete", new JObject()
.Summary("Delete entity in EntitySet " + entitySet.Name)
.Description("Delete entity in EntitySet " + entitySet.Name)
.Tags(entitySet.Name)
.Parameters((keyParameters.DeepClone() as JArray)
.Parameter("If-Match", "header", "If-Match header", "string")
)
.Responses(new JObject()
.Response("204", "Empty response")
.DefaultErrorResponse()
)
}
};
}