JavaScriptEngineSwitcher.ChakraCore.JsRt.JsValue.DefineProperty C# (CSharp) Method

DefineProperty() public method

Defines a new object's own property from a property descriptor
Requires an active script context.
public DefineProperty ( JsPropertyId propertyId, JsValue propertyDescriptor ) : bool
propertyId JsPropertyId The ID of the property
propertyDescriptor JsValue The property descriptor
return bool
		public bool DefineProperty(JsPropertyId propertyId, JsValue propertyDescriptor)
		{
			bool result;
			JsErrorHelpers.ThrowIfError(NativeMethods.JsDefineProperty(this, propertyId, propertyDescriptor, out result));

			return result;
		}

Usage Example

        private static void SetNonEnumerableProperty(JsValue objValue, string name, JsValue value)
        {
            JsValue descriptorValue = JsValue.CreateObject();

            descriptorValue.SetProperty("enumerable", JsValue.False, true);
            descriptorValue.SetProperty("writable", JsValue.True, true);

            JsPropertyId id = JsPropertyId.FromString(name);

            objValue.DefineProperty(id, descriptorValue);
            objValue.SetProperty(id, value, true);
        }
All Usage Examples Of JavaScriptEngineSwitcher.ChakraCore.JsRt.JsValue::DefineProperty