예제 #1
0
        /// <summary>
        /// Determines whether an object has a property
        /// </summary>
        /// <remarks>
        /// Requires an active script context.
        /// </remarks>
        /// <param name="source">The JavaScript value</param>
        /// <param name="propertyName">The name of the property</param>
        /// <returns>Whether the object (or a prototype) has the property</returns>
        public static bool HasProperty(this EdgeJsValue source, string propertyName)
        {
            EdgeJsPropertyId propertyId = EdgeJsPropertyId.FromString(propertyName);
            bool             result     = source.HasProperty(propertyId);

            return(result);
        }
        /// <summary>
        /// Defines a new object's own property from a property descriptor
        /// </summary>
        /// <remarks>
        /// Requires an active script context.
        /// </remarks>
        /// <param name="source">The JavaScript value</param>
        /// <param name="propertyName">The name of the property</param>
        /// <param name="propertyDescriptor">The property descriptor</param>
        /// <returns>Whether the property was defined</returns>
        public static bool DefineProperty(this EdgeJsValue source, string propertyName, EdgeJsValue propertyDescriptor)
        {
            EdgeJsPropertyId propertyId = EdgeJsPropertyId.FromString(propertyName);
            bool result = source.DefineProperty(propertyId, propertyDescriptor);

            return result;
        }
예제 #3
0
        /// <summary>
        /// Deletes an object's property
        /// </summary>
        /// <remarks>
        /// Requires an active script context.
        /// </remarks>
        /// <param name="source">The JavaScript value</param>
        /// <param name="propertyName">The name of the property</param>
        /// <param name="useStrictRules">The property set should follow strict mode rules</param>
        /// <returns>Whether the property was deleted</returns>
        public static EdgeJsValue DeleteProperty(this EdgeJsValue source, string propertyName, bool useStrictRules)
        {
            EdgeJsPropertyId propertyId  = EdgeJsPropertyId.FromString(propertyName);
            EdgeJsValue      resultValue = source.DeleteProperty(propertyId, useStrictRules);

            return(resultValue);
        }
예제 #4
0
        /// <summary>
        /// Gets an object's property
        /// </summary>
        /// <remarks>
        /// Requires an active script context.
        /// </remarks>
        /// <param name="source">The JavaScript value</param>
        /// <param name="name">The name of the property</param>
        /// <returns>The value of the property</returns>
        public static EdgeJsValue GetProperty(this EdgeJsValue source, string name)
        {
            EdgeJsPropertyId id          = EdgeJsPropertyId.FromString(name);
            EdgeJsValue      resultValue = source.GetProperty(id);

            return(resultValue);
        }
예제 #5
0
        /// <summary>
        /// Gets a property descriptor for an object's own property
        /// </summary>
        /// <remarks>
        /// Requires an active script context.
        /// </remarks>
        /// <param name="source">The JavaScript value</param>
        /// <param name="propertyName">The name of the property</param>
        /// <returns>The property descriptor</returns>
        public static EdgeJsValue GetOwnPropertyDescriptor(this EdgeJsValue source, string propertyName)
        {
            EdgeJsPropertyId propertyId  = EdgeJsPropertyId.FromString(propertyName);
            EdgeJsValue      resultValue = source.GetOwnPropertyDescriptor(propertyId);

            return(resultValue);
        }
예제 #6
0
        /// <summary>
        /// Defines a new object's own property from a property descriptor
        /// </summary>
        /// <remarks>
        /// Requires an active script context.
        /// </remarks>
        /// <param name="source">The JavaScript value</param>
        /// <param name="propertyName">The name of the property</param>
        /// <param name="propertyDescriptor">The property descriptor</param>
        /// <returns>Whether the property was defined</returns>
        public static bool DefineProperty(this EdgeJsValue source, string propertyName, EdgeJsValue propertyDescriptor)
        {
            EdgeJsPropertyId propertyId = EdgeJsPropertyId.FromString(propertyName);
            bool             result     = source.DefineProperty(propertyId, propertyDescriptor);

            return(result);
        }
예제 #7
0
        /// <summary>
        /// Creates a new JavaScript URIError error object
        /// </summary>
        /// <remarks>
        /// Requires an active script context.
        /// </remarks>
        /// <param name="message">The message that describes the error</param>
        /// <returns>The new error object</returns>
        public static EdgeJsValue CreateUriError(string message)
        {
            EdgeJsValue messageValue = EdgeJsValue.FromString(message);
            EdgeJsValue errorValue   = EdgeJsValue.CreateUriError(messageValue);

            return(errorValue);
        }
예제 #8
0
        /// <summary>
        /// Sets a exception
        /// </summary>
        /// <remarks>
        /// Requires an active script context.
        /// </remarks>
        /// <param name="exception">The error object</param>
        public static void SetException(EdgeJsValue exception)
        {
            JsErrorCode innerError = EdgeNativeMethods.JsSetException(exception);

            if (innerError != JsErrorCode.NoError)
            {
                throw new JsFatalException(innerError);
            }
        }
 /// <summary>
 /// Sets an object's property
 /// </summary>
 /// <remarks>
 /// Requires an active script context.
 /// </remarks>
 /// <param name="source">The JavaScript value</param>
 /// <param name="name">The name of the property</param>
 /// <param name="value">The new value of the property</param>
 /// <param name="useStrictRules">The property set should follow strict mode rules</param>
 public static void SetProperty(this EdgeJsValue source, string name, EdgeJsValue value, bool useStrictRules)
 {
     EdgeJsPropertyId id = EdgeJsPropertyId.FromString(name);
     source.SetProperty(id, value, useStrictRules);
 }
예제 #10
0
        /// <summary>
        /// Sets an object's property
        /// </summary>
        /// <remarks>
        /// Requires an active script context.
        /// </remarks>
        /// <param name="source">The JavaScript value</param>
        /// <param name="name">The name of the property</param>
        /// <param name="value">The new value of the property</param>
        /// <param name="useStrictRules">The property set should follow strict mode rules</param>
        public static void SetProperty(this EdgeJsValue source, string name, EdgeJsValue value, bool useStrictRules)
        {
            EdgeJsPropertyId id = EdgeJsPropertyId.FromString(name);

            source.SetProperty(id, value, useStrictRules);
        }
 /// <summary>
 /// Sets a exception
 /// </summary>
 /// <remarks>
 /// Requires an active script context.
 /// </remarks>
 /// <param name="exception">The error object</param>
 public static void SetException(EdgeJsValue exception)
 {
     JsErrorCode innerError = EdgeNativeMethods.JsSetException(exception);
     if (innerError != JsErrorCode.NoError)
     {
         throw new JsFatalException(innerError);
     }
 }