123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198 |
- using System;
- namespace I2.Loc.SimpleJSON
- {
- internal class JSONLazyCreator : JSONNode
- {
- public JSONLazyCreator(JSONNode aNode)
- {
- this.m_Node = aNode;
- this.m_Key = null;
- }
- public JSONLazyCreator(JSONNode aNode, string aKey)
- {
- this.m_Node = aNode;
- this.m_Key = aKey;
- }
- private void Set(JSONNode aVal)
- {
- if (this.m_Key == null)
- {
- this.m_Node.Add(aVal);
- }
- else
- {
- this.m_Node.Add(this.m_Key, aVal);
- }
- this.m_Node = null;
- }
- public override JSONNode this[int aIndex]
- {
- get
- {
- return new JSONLazyCreator(this);
- }
- set
- {
- this.Set(new JSONArray
- {
- value
- });
- }
- }
- public override JSONNode this[string aKey]
- {
- get
- {
- return new JSONLazyCreator(this, aKey);
- }
- set
- {
- this.Set(new JSONClass
- {
- {
- aKey,
- value
- }
- });
- }
- }
- public override void Add(JSONNode aItem)
- {
- this.Set(new JSONArray
- {
- aItem
- });
- }
- public override void Add(string aKey, JSONNode aItem)
- {
- this.Set(new JSONClass
- {
- {
- aKey,
- aItem
- }
- });
- }
- public static bool operator ==(JSONLazyCreator a, object b)
- {
- return b == null || object.ReferenceEquals(a, b);
- }
- public static bool operator !=(JSONLazyCreator a, object b)
- {
- return !(a == b);
- }
- public override bool Equals(object obj)
- {
- return obj == null || object.ReferenceEquals(this, obj);
- }
- public override int GetHashCode()
- {
- return base.GetHashCode();
- }
- public override string ToString()
- {
- return string.Empty;
- }
- public override string ToString(string aPrefix)
- {
- return string.Empty;
- }
- public override int AsInt
- {
- get
- {
- JSONData aVal = new JSONData(0);
- this.Set(aVal);
- return 0;
- }
- set
- {
- JSONData aVal = new JSONData(value);
- this.Set(aVal);
- }
- }
- public override float AsFloat
- {
- get
- {
- JSONData aVal = new JSONData(0f);
- this.Set(aVal);
- return 0f;
- }
- set
- {
- JSONData aVal = new JSONData(value);
- this.Set(aVal);
- }
- }
- public override double AsDouble
- {
- get
- {
- JSONData aVal = new JSONData(0.0);
- this.Set(aVal);
- return 0.0;
- }
- set
- {
- JSONData aVal = new JSONData(value);
- this.Set(aVal);
- }
- }
- public override bool AsBool
- {
- get
- {
- JSONData aVal = new JSONData(false);
- this.Set(aVal);
- return false;
- }
- set
- {
- JSONData aVal = new JSONData(value);
- this.Set(aVal);
- }
- }
- public override JSONArray AsArray
- {
- get
- {
- JSONArray jsonarray = new JSONArray();
- this.Set(jsonarray);
- return jsonarray;
- }
- }
- public override JSONClass AsObject
- {
- get
- {
- JSONClass jsonclass = new JSONClass();
- this.Set(jsonclass);
- return jsonclass;
- }
- }
- private JSONNode m_Node;
- private string m_Key;
- }
- }
|