GetProperty() public method

Gets a object's property
Requires an active script context.
public GetProperty ( EdgeJsPropertyId id ) : EdgeJsValue
id EdgeJsPropertyId The ID of the property
return EdgeJsValue
        public override object CallFunction(string functionName, params object[] args)
        {
            object result = InvokeScript(() =>
            {
                EdgeJsValue globalObj       = EdgeJsValue.GlobalObject;
                EdgeJsPropertyId functionId = EdgeJsPropertyId.FromString(functionName);

                bool functionExist = globalObj.HasProperty(functionId);
                if (!functionExist)
                {
                    throw new JsRuntimeException(
                        string.Format(CommonStrings.Runtime_FunctionNotExist, functionName));
                }

                EdgeJsValue resultValue;
                EdgeJsValue functionValue = globalObj.GetProperty(functionId);

                if (args.Length > 0)
                {
                    EdgeJsValue[] processedArgs = MapToScriptType(args);

                    foreach (EdgeJsValue processedArg in processedArgs)
                    {
                        AddReferenceToValue(processedArg);
                    }

                    EdgeJsValue[] allProcessedArgs = new[] { globalObj }.Concat(processedArgs).ToArray();
                    resultValue = functionValue.CallFunction(allProcessedArgs);

                    foreach (EdgeJsValue processedArg in processedArgs)
                    {
                        RemoveReferenceToValue(processedArg);
                    }
                }
                else
                {
                    resultValue = functionValue.CallFunction(globalObj);
                }

                return(MapToHostType(resultValue));
            });

            return(result);
        }
        public override bool HasVariable(string variableName)
        {
            bool result = InvokeScript(() =>
            {
                EdgeJsValue globalObj       = EdgeJsValue.GlobalObject;
                EdgeJsPropertyId variableId = EdgeJsPropertyId.FromString(variableName);
                bool variableExist          = globalObj.HasProperty(variableId);

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

                return(variableExist);
            });

            return(result);
        }
        private JsRuntimeException ConvertJsExceptionToJsRuntimeException(
            JsException jsException)
        {
            string message        = jsException.Message;
            string category       = string.Empty;
            int    lineNumber     = 0;
            int    columnNumber   = 0;
            string sourceFragment = string.Empty;

            var jsScriptException = jsException as EdgeJsScriptException;

            if (jsScriptException != null)
            {
                category = "Script error";
                EdgeJsValue errorValue = jsScriptException.Error;

                EdgeJsPropertyId stackPropertyId = EdgeJsPropertyId.FromString("stack");
                if (errorValue.HasProperty(stackPropertyId))
                {
                    EdgeJsValue stackPropertyValue = errorValue.GetProperty(stackPropertyId);
                    message = stackPropertyValue.ConvertToString().ToString();
                }
                else
                {
                    EdgeJsValue messagePropertyValue = errorValue.GetProperty("message");
                    string      scriptMessage        = messagePropertyValue.ConvertToString().ToString();
                    if (!string.IsNullOrWhiteSpace(scriptMessage))
                    {
                        message = string.Format("{0}: {1}", message.TrimEnd('.'), scriptMessage);
                    }
                }

                EdgeJsPropertyId linePropertyId = EdgeJsPropertyId.FromString("line");
                if (errorValue.HasProperty(linePropertyId))
                {
                    EdgeJsValue linePropertyValue = errorValue.GetProperty(linePropertyId);
                    lineNumber = linePropertyValue.ConvertToNumber().ToInt32() + 1;
                }

                EdgeJsPropertyId columnPropertyId = EdgeJsPropertyId.FromString("column");
                if (errorValue.HasProperty(columnPropertyId))
                {
                    EdgeJsValue columnPropertyValue = errorValue.GetProperty(columnPropertyId);
                    columnNumber = columnPropertyValue.ConvertToNumber().ToInt32() + 1;
                }

                if (lineNumber <= 0 && columnNumber <= 0)
                {
                    GetErrorCoordinatesFromMessage(message, out lineNumber, out columnNumber);
                }

                EdgeJsPropertyId sourcePropertyId = EdgeJsPropertyId.FromString("source");
                if (errorValue.HasProperty(sourcePropertyId))
                {
                    EdgeJsValue sourcePropertyValue = errorValue.GetProperty(sourcePropertyId);
                    sourceFragment = sourcePropertyValue.ConvertToString().ToString();
                }
            }
            else if (jsException is JsUsageException)
            {
                category = "Usage error";
            }
            else if (jsException is JsEngineException)
            {
                category = "Engine error";
            }
            else if (jsException is JsFatalException)
            {
                category = "Fatal error";
            }

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

            return(jsEngineException);
        }