public static void ReadValue(this IJSValueReader reader, out bool value)
        {
            switch (reader.ValueType)
            {
            case JSValueType.String: value = !string.IsNullOrEmpty(reader.GetString()); break;

            case JSValueType.Boolean: value = reader.GetBoolean(); break;

            case JSValueType.Int64: value = reader.GetInt64() != 0; break;

            case JSValueType.Double: value = reader.GetDouble() != 0; break;

            default: value = false; break;
            }
        }
        public static void ReadValue(this IJSValueReader reader, out string value)
        {
            switch (reader.ValueType)
            {
            case JSValueType.String: value = reader.GetString(); break;

            case JSValueType.Boolean: value = reader.GetBoolean() ? "true" : "false"; break;

            case JSValueType.Int64: value = reader.GetInt64().ToString(); break;

            case JSValueType.Double: value = reader.GetDouble().ToString(); break;

            default: value = ""; break;
            }
        }
Пример #3
0
        private static JSValue ReadValue(IJSValueReader reader)
        {
            switch (reader.ValueType)
            {
            case JSValueType.Null: return(Null);

            case JSValueType.Object: return(ReadObject(reader));

            case JSValueType.Array: return(ReadArray(reader));

            case JSValueType.String: return(new JSValue(reader.GetString()));

            case JSValueType.Boolean: return(new JSValue(reader.GetBoolean()));

            case JSValueType.Int64: return(new JSValue(reader.GetInt64()));

            case JSValueType.Double: return(new JSValue(reader.GetDouble()));

            default: throw new ReactException("Unexpected JSValueType");
            }
        }
        public static void ReadValue(this IJSValueReader reader, out long value)
        {
            switch (reader.ValueType)
            {
            case JSValueType.String:
            {
                if (!long.TryParse(reader.GetString(), out value))
                {
                    value = 0;
                }
                break;
            }

            case JSValueType.Boolean: value = reader.GetBoolean() ? 1 : 0; break;

            case JSValueType.Int64: value = reader.GetInt64(); break;

            case JSValueType.Double: value = (long)reader.GetDouble(); break;

            default: value = 0; break;
            }
        }