MsieJavaScriptEngine.JsRt.JavaScriptValue.GetProperty C# (CSharp) Method

GetProperty() public method

Gets an object's property.
Requires an active script context.
public GetProperty ( JavaScriptPropertyId id ) : JavaScriptValue
id JavaScriptPropertyId The ID of the property.
return JavaScriptValue
        public JavaScriptValue GetProperty(JavaScriptPropertyId id)
        {
            JavaScriptValue propertyReference;
            Native.ThrowIfError(Native.JsGetProperty(this, id, out propertyReference));
            return propertyReference;
        }

Usage Example

        public bool HasVariable(string variableName)
        {
            bool result = InvokeScript(() =>
            {
                JavaScriptValue globalObj       = JavaScriptValue.GlobalObject;
                JavaScriptPropertyId variableId = JavaScriptPropertyId.FromString(variableName);
                bool variableExist = globalObj.HasProperty(variableId);

                if (variableExist)
                {
                    JavaScriptValue variableValue = globalObj.GetProperty(variableId);
                    variableExist = (variableValue.ValueType != JavaScriptValueType.Undefined);
                }

                return(variableExist);
            });

            return(result);
        }
All Usage Examples Of MsieJavaScriptEngine.JsRt.JavaScriptValue::GetProperty