本文整理汇总了C#中JSObject.SetProperty方法的典型用法代码示例。如果您正苦于以下问题:C# JSObject.SetProperty方法的具体用法?C# JSObject.SetProperty怎么用?C# JSObject.SetProperty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JSObject
的用法示例。
在下文中一共展示了JSObject.SetProperty方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DeleteDontDeletePropertyTest
public void DeleteDontDeletePropertyTest()
{
var obj = new JSObject (context, null);
obj.SetProperty ("foo", new JSValue (context, "i am permanent"), JSPropertyAttribute.DontDelete);
Assert.IsTrue (obj.HasProperty ("foo"));
Assert.IsFalse (obj.DeleteProperty ("foo"));
Assert.IsTrue (obj.HasProperty ("foo"));
}
示例2: DeletePropertyTest
public void DeletePropertyTest()
{
var obj = new JSObject (context, null);
obj.SetProperty ("foo", new JSValue (context, "bar"));
Assert.IsTrue (obj.HasProperty ("foo"));
Assert.IsTrue (obj.DeleteProperty ("foo"));
Assert.IsFalse (obj.HasProperty ("foo"));
obj.SetProperty ("foo", new JSValue (context, 99));
Assert.IsTrue (obj.HasProperty ("foo"));
Assert.IsTrue (obj.DeleteProperty ("foo"));
Assert.IsFalse (obj.HasProperty ("foo"));
}
示例3: GetPropertyOverrideTest
public void GetPropertyOverrideTest()
{
var default_obj = new JSObject (context);
default_obj.SetProperty ("name", new JSValue (context, "abock"));
var override_obj = new JSObject (context, new GetPropertyClassTest ().CreateClass ());
override_obj.SetProperty ("name", new JSValue (context, "ranger"));
Assert.AreEqual ("{\"name\":\"abock\"}", default_obj.ToJsonString (0));
Assert.AreEqual ("{\"name\":\"always this\"}", override_obj.ToJsonString (0));
}
示例4: SetPropertyTest
public void SetPropertyTest()
{
var obj = new JSObject (context, null);
var prop = new JSValue (context, "happy days");
obj.SetProperty ("str", prop);
Assert.IsTrue (obj.HasProperty ("str"));
Assert.IsTrue (obj.GetProperty ("str").IsEqual (prop));
Assert.IsTrue (obj.GetProperty ("str").IsStrictEqual (prop));
Assert.AreEqual ("happy days", obj.GetProperty ("str").StringValue);
obj.SetProperty ("str", obj);
Assert.IsTrue (obj.GetProperty ("str").IsEqual (obj));
Assert.IsTrue (obj.GetProperty ("str").IsStrictEqual (obj));
}
示例5: ReadOnlyPropertyTest
public void ReadOnlyPropertyTest()
{
var obj = new JSObject (context, null);
obj.SetProperty ("foo", new JSValue (context, "bar"), JSPropertyAttribute.ReadOnly);
Assert.AreEqual ("bar", obj.GetProperty ("foo").StringValue);
obj.SetProperty ("foo", new JSValue (context, "baz"));
Assert.AreEqual ("bar", obj.GetProperty ("foo").StringValue);
Assert.IsTrue (obj.DeleteProperty ("foo"));
Assert.IsFalse (obj.HasProperty ("foo"));
}