コード例 #1
0
 internal TimeValue(JsonValue value)
 {
     JsonObject obj = value.asObject();
     this.time = obj.get("time").asString();
     this.timezone = obj.get("timezone").asInt();
     this.before = obj.get("before").asInt();
     this.after = obj.get("after").asInt();
     this.precision = obj.get("precision").asInt();
     this.calendarmodel = obj.get("calendarmodel").asString();
 }
コード例 #2
0
 internal GlobeCoordinateValue(JsonValue value)
 {
     JsonObject obj = value.asObject();
     this.latitude = obj.get("latitude").asDouble();
     this.longitude = obj.get("longitude").asDouble();
     this.altitude = obj.get("altitude");
     JsonValue precisionReceived = obj.get("precision");
     if ( precisionReceived != JsonValue.NULL )
     {
         this.precision = precisionReceived.asDouble();
     }
     this.globe = obj.get("globe").asString();
 }
コード例 #3
0
 internal static DataValue newDataValue(string type, JsonValue value)
 {
     switch (type)
     {
         case "wikibase-entityid":
             return new EntityIdValue(value);
         case "string":
             return new StringValue(value);
         case "time":
             return new TimeValue(value);
         case "globecoordinate":
             return new GlobeCoordinateValue(value);
         default:
             throw new NotSupportedException("Unsupported type " + type);
     }
 }
コード例 #4
0
ファイル: JsonArray.cs プロジェクト: ericvoid/minimaljson.net
 /// <summary>
 /// Removes the first appereance of the value in this array.
 /// </summary>
 /// <param name="value">the value to be removed from this array</param>
 /// <returns>true if the value was successfully removed, false if it didn't exist</returns>
 public bool remove(JsonValue value)
 {
     return values.Remove(value);
 }
コード例 #5
0
ファイル: JsonArray.cs プロジェクト: ericvoid/minimaljson.net
 /// <summary>
 /// Replaces the element at the specified position in this array with the JSON representation of the specified JSON value.
 /// </summary>
 /// <param name="index">the index of the array element to replace</param>
 /// <param name="value">the value to be stored at the specified array position, must not be <code>null</code></param>
 /// <returns>the array itself, to enable method chaining</returns>
 /// <exception cref="ArgumentNullException">if the value is <code>null</code></exception>
 /// <exception cref="ArgumentOutOfRangeException">if the index is out of range, i.e. <code>index &lt; 0</code> or <code>index >= size</code></exception>
 public JsonArray set(int index, JsonValue value)
 {
     if (value == null)
     {
         throw new ArgumentNullException("value");
     }
     values[index] = value;
     return this;
 }
コード例 #6
0
ファイル: JsonArray.cs プロジェクト: ericvoid/minimaljson.net
 /// <summary>
 /// Adds the JSON representation of the specified JSON value to the array.
 /// </summary>
 /// <param name="value">the value to add to the array, must not be <code>null</code></param>
 /// <returns>the array itself, to enable method chaining</returns>
 /// <exception cref="ArgumentNullException">if the value is <code>null</code></exception>
 public JsonArray add(JsonValue value)
 {
     if (value == null)
     {
         throw new ArgumentNullException("value is null");
     }
     values.Add(value);
     return this;
 }
コード例 #7
0
 internal EntityIdValue(JsonValue value)
 {
     JsonObject obj = value.asObject();
     this.entityType = obj.get("entity-type").asString();
     this.numericId = obj.get("numeric-id").asInt();
 }
コード例 #8
0
 internal StringValue(JsonValue value)
 {
     this.str = value.asString();
 }
コード例 #9
0
 internal Member(string name, JsonValue value)
 {
     this.name = name;
     this.value = value;
 }
コード例 #10
0
 /// <summary>
 /// Sets the value of the member with the specified name to the JSON representation of the specified JSON value.
 /// If this object does not contain a member with this name, a new member is added at the end of the object.
 /// </summary>
 /// <param name="name">the name of the member to replace</param>
 /// <param name="value">the value to set to the member, must not be <code>null</code></param>
 /// <returns>the object itself, to enable method chaining</returns>
 /// <exception cref="ArgumentNullException">if the value is <code>null</code></exception>
 public JsonObject set(string name, JsonValue value)
 {
     if (value == null)
     {
         throw new ArgumentNullException("value");
     }
     values[name] = value;
     return this;
 }
コード例 #11
0
 /// <summary>
 /// Adds a new member at the end of this object, with the specified name and the specified JSON value.
 /// </summary>
 /// <param name="name">the name of the member to add</param>
 /// <param name="value">the value of the member to add, must not be <code>null</code></param>
 /// <returns>the object itself, to enable method chaining</returns>
 /// <exception cref="ArgumentNullException">if the value is <code>null</code></exception>
 public JsonObject add(string name, JsonValue value)
 {
     if (value == null)
     {
         throw new ArgumentNullException("value");
     }
     values.Add(name, value);
     return this;
 }