Esempio n. 1
0
 public void AddObject(JSONObject obj)
 {
     objectBuilding.Add(obj);
 }
Esempio n. 2
0
 public ConstructBoolean(string firstCharacter)
 {
     objBuilding = new JSONObject();
     strBuilder = new StringBuilder();
     strBuilder.Append(firstCharacter);
 }
Esempio n. 3
0
 public ConstructArray()
 {
     objectBuilding = new JSONObject();
     objectBuilding.InitializeArray();
 }
Esempio n. 4
0
 public JSONObject DoConstruction(string ch, JSONParser parser)
 {
     if (ch.Equals("\"")) {
         // finished string
         objectBuilding = strBuilder.ToString();
         return objectBuilding;
     } else {
         strBuilder.Append(ch);
     }
     return null;
 }
Esempio n. 5
0
 public ConstructString()
 {
     objectBuilding = new JSONObject();
     strBuilder = new StringBuilder();
 }
Esempio n. 6
0
 public void AddObject(JSONObject obj)
 {
     throw new InvalidOperationException("Objects cannot be added to ConstructString construct");
 }
Esempio n. 7
0
 public ConstructObject()
 {
     currentKey = null;
     objectBuilding = new JSONObject();
 }
Esempio n. 8
0
 public void AddObject(JSONObject obj)
 {
     if (currentKey == null) {
         currentKey = obj;
     } else {
         objectBuilding.AddChild(currentKey, obj);
         currentKey = null;
     }
 }
Esempio n. 9
0
 public ConstructNull()
 {
     objBuidling = new JSONObject();
     objBuidling.SetAsNull();
 }
Esempio n. 10
0
 public void AddObject(JSONObject obj)
 {
     throw new InvalidOperationException("Cannot add objects to ConstructNull construct");
 }
Esempio n. 11
0
 public JSONObject DoConstruction(string ch, JSONParser parser)
 {
     if (ch.Equals(",") || ch.Equals("]") || ch.Equals("}")) {
         // return object
         objBuilding = Double.Parse(strBuilder.ToString());
         return objBuilding;
     } else {
         strBuilder.Append(ch);
     }
     return null;
 }
Esempio n. 12
0
 private bool CheckDataConsistency(JSONObject value)
 {
     // check that the value being sent in is consistent with other data points
     bool retval = true;
     if (array.Count > 0) {
         Console.Out.WriteLine("value type: " + value.type.ToString());
         Console.Out.WriteLine("Array type: " + array[0].type.ToString());
         if (value.type != array[0].type)
             retval = false;
     }
     return retval;
 }
Esempio n. 13
0
 public void AddChild(string key, JSONObject child)
 {
     if (this.type == JsonType.jobj) {
         this.children.Add(key, child);
     }
 }
Esempio n. 14
0
 public void Add(JSONObject child)
 {
     if (this.type == JsonType.jarr) {
         this.array.Add(child);
     }
 }
Esempio n. 15
0
 /// <summary>
 /// Returns the child by index. If the index is greater than the current count, add a new object at the largest index.
 /// </summary>
 /// <param name="key">Index to get the child</param>
 /// <returns>The child at the index, or a new child at the largest index</returns>
 public JSONObject this[int key]
 {
     get {
         if (array != null) {
             if (key < array.Count) {
                 return array[key];
             } else {
                 array.Add(new JSONObject());
                 return array[array.Count - 1];
             }
         }
         return null;
     }
     set {
         if (array != null) {
             if (CheckDataConsistency(value)) {
                 if (key < array.Count)
                     array[key] = value;
                 else {
                     JSONObject jo = new JSONObject();
                     jo = value;
                     array.Add(jo);
                 }
             } else {
                 throw new ArrayTypeMismatchException("Cannot add value " + value.ToString() + " to data array");
             }
         }
     }
 }