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

Converts a value to Number using regular JavaScript semantics
Requires an active script context.
public ConvertToNumber ( ) : EdgeJsValue
Результат EdgeJsValue
        /// <summary>
        /// Makes a mapping of value from the script type to a host type
        /// </summary>
        /// <param name="value">The source value</param>
        /// <returns>The mapped value</returns>
        private object MapToHostType(EdgeJsValue value)
        {
            JsValueType valueType = value.ValueType;
            EdgeJsValue processedValue;
            object      result;

            switch (valueType)
            {
            case JsValueType.Null:
                result = null;
                break;

            case JsValueType.Undefined:
                result = Undefined.Value;
                break;

            case JsValueType.Boolean:
                processedValue = value.ConvertToBoolean();
                result         = processedValue.ToBoolean();
                break;

            case JsValueType.Number:
                processedValue = value.ConvertToNumber();
                result         = NumericHelpers.CastDoubleValueToCorrectType(processedValue.ToDouble());
                break;

            case JsValueType.String:
                processedValue = value.ConvertToString();
                result         = processedValue.ToString();
                break;

            case JsValueType.Object:
            case JsValueType.Function:
            case JsValueType.Error:
            case JsValueType.Array:
#if NETSTANDARD1_3
                result = ToObject(value);
#else
                processedValue = value.ConvertToObject();
                object obj = processedValue.ToObject();

                if (!TypeConverter.IsPrimitiveType(obj.GetType()))
                {
                    var hostObj = obj as HostObject;
                    result = hostObj != null ? hostObj.Target : obj;
                }
                else
                {
                    result = obj;
                }
#endif
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            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);
        }