Ejemplo n.º 1
0
        /// <summary>
        /// Writes a JSON array of JSON strings given an array of
        /// <see cref="String"/> values.
        /// </summary>

        public void WriteStringArray(params string[] values)
        {
            if (values == null)
            {
                WriteNull();
            }
            else
            {
                WriteStartArray();

                foreach (string value in values)
                {
                    if (JsonNull.LogicallyEquals(value))
                    {
                        WriteNull();
                    }
                    else
                    {
                        WriteString(value);
                    }
                }

                WriteEndArray();
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Writes a JSON array of JSON strings given an enumerable source
        /// of arbitrary <see cref="Object"/> values.
        /// </summary>

        public void WriteStringArray(IEnumerable values)
        {
            if (values == null)
            {
                WriteNull();
            }
            else
            {
                WriteStartArray();

                foreach (object value in values)
                {
                    if (JsonNull.LogicallyEquals(value))
                    {
                        WriteNull();
                    }
                    else
                    {
                        WriteString(value.ToString());
                    }
                }

                WriteEndArray();
            }
        }
Ejemplo n.º 3
0
 public void LogicalEquality()
 {
     Assert.IsTrue(JsonNull.LogicallyEquals(JsonNull.Value), "Equals self?");
     Assert.IsFalse(JsonNull.LogicallyEquals(new object()), "Equals non-nullable?");
     Assert.IsTrue(JsonNull.LogicallyEquals(null), "Equals null reference?");
     Assert.IsTrue(JsonNull.LogicallyEquals(DBNull.Value), "Equals DBNull?");
 }
Ejemplo n.º 4
0
        public void InitWithExtraKeys()
        {
            JsonObject o = new JsonObject(new string[] { "one", "two", "three" }, new object[] { 1, 2 });

            Assert.AreEqual(3, o.Count);
            Assert.AreEqual(1, o["one"]);
            Assert.AreEqual(2, o["two"]);
            Assert.IsTrue(JsonNull.LogicallyEquals(o["three"]));
        }
Ejemplo n.º 5
0
        public void InitWithNullValues()
        {
            JsonObject o = new JsonObject(new string[] { "one", "two", "three" }, null);

            Assert.AreEqual(3, o.Count);
            Assert.IsTrue(JsonNull.LogicallyEquals(o["one"]));
            Assert.IsTrue(JsonNull.LogicallyEquals(o["two"]));
            Assert.IsTrue(JsonNull.LogicallyEquals(o["three"]));
        }