public void CreateWithMultiValue() { JConstructor constructor = new JConstructor("Test", new List <int> { 1, 2, 3 }); Assert.AreEqual("Test", constructor.Name); Assert.AreEqual(3, constructor.Children().Count()); Assert.AreEqual(1, (int)constructor.Children().ElementAt(0)); Assert.AreEqual(2, (int)constructor.Children().ElementAt(1)); Assert.AreEqual(3, (int)constructor.Children().ElementAt(2)); }
private void WriteToken(JSchema context, JsonWriter writer, JToken token) { if (token is JObject) { JObject o = (JObject)token; JSchemaAnnotation schemaAnnotation = o.Annotation <JSchemaAnnotation>(); if (schemaAnnotation != null) { ReferenceOrWriteSchema(context, schemaAnnotation.Schema, null); } else { writer.WriteStartObject(); foreach (JProperty property in o.Properties()) { writer.WritePropertyName(property.Name); JToken value = property.Value; if (value != null) { WriteToken(context, writer, value); } else { writer.WriteNull(); } } writer.WriteEndObject(); } } else if (token is JArray) { JArray a = (JArray)token; writer.WriteStartArray(); for (int i = 0; i < a.Count; i++) { WriteToken(context, writer, a[i]); } writer.WriteEndArray(); } else if (token is JConstructor) { JConstructor c = (JConstructor)token; writer.WriteStartConstructor(c.Name); foreach (JToken t in c.Children()) { WriteToken(context, writer, t); } writer.WriteEndConstructor(); } else if (token is JValue) { token.WriteTo(writer); } }