2019-08-07 23:02:00 +02:00
|
|
|
|
// /**
|
|
|
|
|
// * File: JSONValue.cs
|
|
|
|
|
// * Author: haraldwolff
|
|
|
|
|
// *
|
|
|
|
|
// * This file and it's content is copyrighted by the Author and / or copyright holder.
|
|
|
|
|
// * Any use wihtout proper permission is illegal and may lead to legal actions.
|
|
|
|
|
// *
|
|
|
|
|
// *
|
|
|
|
|
// **/
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2019-12-13 15:34:31 +01:00
|
|
|
|
using ln.json.mapping;
|
2019-08-07 23:02:00 +02:00
|
|
|
|
namespace ln.json
|
|
|
|
|
{
|
|
|
|
|
public enum JSONValueType
|
|
|
|
|
{
|
|
|
|
|
NULL, OBJECT, ARRAY, STRING, NUMBER, TRUE, FALSE
|
|
|
|
|
}
|
|
|
|
|
public abstract class JSONValue
|
|
|
|
|
{
|
|
|
|
|
public JSONValueType ValueType { get; private set; }
|
|
|
|
|
|
|
|
|
|
public virtual bool HasChildren => false;
|
|
|
|
|
public virtual IEnumerable<JSONValue> Children => throw new NotSupportedException();
|
|
|
|
|
|
2019-08-19 14:14:15 +02:00
|
|
|
|
public virtual object ToNative() => throw new NotImplementedException();
|
|
|
|
|
|
2019-08-07 23:02:00 +02:00
|
|
|
|
public JSONValue(JSONValueType valueType)
|
|
|
|
|
{
|
|
|
|
|
ValueType = valueType;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public virtual JSONValue this[string property]
|
|
|
|
|
{
|
|
|
|
|
get => throw new NotSupportedException();
|
|
|
|
|
set => throw new NotSupportedException();
|
|
|
|
|
}
|
|
|
|
|
public virtual JSONValue this[int index]
|
|
|
|
|
{
|
|
|
|
|
get => throw new NotSupportedException();
|
|
|
|
|
set => throw new NotSupportedException();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string ToString() => throw new NotImplementedException();
|
2019-12-13 15:34:31 +01:00
|
|
|
|
|
|
|
|
|
public static implicit operator JSONValue(String text) => new JSONString(text);
|
|
|
|
|
public static implicit operator JSONValue(bool b) => b ? (JSONValue)JSONTrue.Instance : (JSONValue)JSONFalse.Instance;
|
|
|
|
|
public static implicit operator JSONValue(int i) => new JSONNumber(i);
|
|
|
|
|
public static implicit operator JSONValue(double d) => new JSONNumber(d);
|
2019-08-07 23:02:00 +02:00
|
|
|
|
}
|
|
|
|
|
}
|