Пример #1
0
 public void AddObject(JSONObject obj)
 {
     objectBuilding.Add(obj);
 }
Пример #2
0
 public ConstructBoolean(string firstCharacter)
 {
     objBuilding = new JSONObject();
     strBuilder = new StringBuilder();
     strBuilder.Append(firstCharacter);
 }
Пример #3
0
 public ConstructArray()
 {
     objectBuilding = new JSONObject();
     objectBuilding.InitializeArray();
 }
Пример #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;
 }
Пример #5
0
 public ConstructString()
 {
     objectBuilding = new JSONObject();
     strBuilder = new StringBuilder();
 }
Пример #6
0
 public void AddObject(JSONObject obj)
 {
     throw new InvalidOperationException("Objects cannot be added to ConstructString construct");
 }
Пример #7
0
 public ConstructObject()
 {
     currentKey = null;
     objectBuilding = new JSONObject();
 }
Пример #8
0
 public void AddObject(JSONObject obj)
 {
     if (currentKey == null) {
         currentKey = obj;
     } else {
         objectBuilding.AddChild(currentKey, obj);
         currentKey = null;
     }
 }
Пример #9
0
 public ConstructNull()
 {
     objBuidling = new JSONObject();
     objBuidling.SetAsNull();
 }
Пример #10
0
 public void AddObject(JSONObject obj)
 {
     throw new InvalidOperationException("Cannot add objects to ConstructNull construct");
 }
Пример #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;
 }
Пример #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;
 }
Пример #13
0
 public void AddChild(string key, JSONObject child)
 {
     if (this.type == JsonType.jobj) {
         this.children.Add(key, child);
     }
 }
Пример #14
0
 public void Add(JSONObject child)
 {
     if (this.type == JsonType.jarr) {
         this.array.Add(child);
     }
 }
Пример #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");
             }
         }
     }
 }