コード例 #1
0
        public void AddPropertyToParentObjectWhileBuildingChildObject()
        {
            JSBuilder builder = new JSBuilder();
            InvalidOperationException exception = Assert.ThrowsException <InvalidOperationException>(() =>
            {
                builder.Object((JSObject parentObject) =>
                {
                    parentObject.ObjectProperty("child", (JSObject childObject) =>
                    {
                        childObject.TextProperty("a", "A");
                        parentObject.TextProperty("b", "B");
                    });
                });
            });

            Assert.AreEqual("Cannot add a property to a JSObject while constructing its child property (\"child\").", exception.Message);
        }
コード例 #2
0
 /// <summary>
 /// Add a JSON object to this TSValue.
 /// </summary>
 /// <param name="objectAction">The action that will be invoked to produce the properties of the JSON object.</param>
 public virtual void Object(Action <JSObject> objectAction = null)
 {
     builder.Object(objectAction);
 }