GetProperty() публичный Метод

Gets an object's property.
Requires an active script context.
public GetProperty ( JavaScriptPropertyId id ) : JavaScriptValue
id JavaScriptPropertyId The ID of the property.
Результат JavaScriptValue
        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);
        }
        private JsRuntimeException ConvertJavaScriptExceptionToJsRuntimeException(
            JavaScriptException jsException)
        {
            string message        = jsException.Message;
            string category       = string.Empty;
            int    lineNumber     = 0;
            int    columnNumber   = 0;
            string sourceFragment = string.Empty;

            if (jsException is JavaScriptScriptException)
            {
                category = "Script error";

                var             jsScriptException = (JavaScriptScriptException)jsException;
                JavaScriptValue errorValue        = jsScriptException.Error;

                JavaScriptPropertyId messagePropertyId    = JavaScriptPropertyId.FromString("message");
                JavaScriptValue      messagePropertyValue = errorValue.GetProperty(messagePropertyId);
                string scriptMessage = messagePropertyValue.ConvertToString().ToString();
                if (!string.IsNullOrWhiteSpace(scriptMessage))
                {
                    message = string.Format("{0}: {1}", message.TrimEnd('.'), scriptMessage);
                }

                JavaScriptPropertyId linePropertyId = JavaScriptPropertyId.FromString("line");
                if (errorValue.HasProperty(linePropertyId))
                {
                    JavaScriptValue linePropertyValue = errorValue.GetProperty(linePropertyId);
                    lineNumber = (int)linePropertyValue.ConvertToNumber().ToDouble() + 1;
                }

                JavaScriptPropertyId columnPropertyId = JavaScriptPropertyId.FromString("column");
                if (errorValue.HasProperty(columnPropertyId))
                {
                    JavaScriptValue columnPropertyValue = errorValue.GetProperty(columnPropertyId);
                    columnNumber = (int)columnPropertyValue.ConvertToNumber().ToDouble() + 1;
                }

                JavaScriptPropertyId sourcePropertyId = JavaScriptPropertyId.FromString("source");
                if (errorValue.HasProperty(sourcePropertyId))
                {
                    JavaScriptValue sourcePropertyValue = errorValue.GetProperty(sourcePropertyId);
                    sourceFragment = sourcePropertyValue.ConvertToString().ToString();
                }
            }
            else if (jsException is JavaScriptUsageException)
            {
                category = "Usage error";
            }
            else if (jsException is JavaScriptEngineException)
            {
                category = "Engine error";
            }
            else if (jsException is JavaScriptFatalException)
            {
                category = "Fatal error";
            }

            var jsEngineException = new JsRuntimeException(message, ENGINE_MODE_NAME)
            {
                ErrorCode      = ((uint)jsException.ErrorCode).ToString(CultureInfo.InvariantCulture),
                Category       = category,
                LineNumber     = lineNumber,
                ColumnNumber   = columnNumber,
                SourceFragment = sourceFragment,
                HelpLink       = jsException.HelpLink
            };

            return(jsEngineException);
        }