示例#1
0
 /// <summary>
 /// Creates a new instance of <see cref="JsonPropertyDefinition"/>.
 /// </summary>
 /// <param name="propertyName">The name of the property.</param>
 /// <param name="category">A category the property belongs.</param>
 /// <param name="description">A description of the property.</param>
 /// <param name="defaultValue">The default value if the property.</param>
 /// <param name="browsable">Can the property be viewed in a control such as PropertyGrid.</param>
 /// <param name="readOnly">Can the property be edited?</param>
 public JsonPropertyDefinition(string propertyName, string category, string description, JsonValue defaultValue, bool browsable, bool readOnly)
 {
     PropertyName = propertyName;
     Category = category;
     Description = description;
     DefaultValue = defaultValue;
     Browsable = browsable;
     ReadOnly = readOnly;
 }
示例#2
0
 /// <summary>
 /// Tries to parse a string of json and determine is <see cref="JsonValue"/> type.
 /// </summary>
 /// <param name="json">A string of json that should be parsed.</param>
 /// <param name="value">The output <see cref="JsonValue"/> created if successful. If not successful, a <see cref="JsonNull"/> se set to <paramref name="value"/>.</param>
 /// <returns>Returns true if <see cref="JsonValue"/> was successfully created; otherwise false is returned.</returns>
 public static bool TryParse(string json, out JsonValue value)
 {
     if (string.IsNullOrEmpty(json))
     {
         value = new JsonNull();
         return true;
     }
     if (json.StartsWith("{", StringComparison.CurrentCulture) && json.EndsWith("}", StringComparison.Ordinal))
     {
         value = new JsonObject(json);
         return true;
     }
     if (json.StartsWith("[") && json.EndsWith("]"))
     {
         value = new JsonArray(json);
         return true;
     }
     if (json.StartsWith("\"") && json.EndsWith("\""))
     {
         json = json.Substring(1, json.Length - 2);
         if (json.StartsWith("base64:"))
             value = new JsonBinary(json);
         else
             value = new JsonString(json);
         return true;
     }
     decimal v;
     bool bv;
     if (decimal.TryParse(json, out v))
     {
         value = new JsonNumber(v);
         return true;
     }
     if (bool.TryParse(json, out bv))
     {
         value = new JsonBoolean(bv);
         return true;
     }
     value = null;
     return false;
 }
示例#3
0
 /// <summary>
 /// Determine if a <see cref="JsonValue"/> is null.
 /// </summary>
 /// <param name="value">A value to determine.</param>
 /// <returns>Returns true if <paramref name="value"/> is null or is a <see cref="JsonNull"/></returns>
 public static bool IsNull(JsonValue value)
 {
     if ((object)value == null)
         return true;
     JsonNull n = value as JsonNull;
     if ((object)n != null)
         return true;
     return false;
 }
示例#4
0
 internal void SetParent(JsonValue parent)
 {
     _parent = parent;
 }
示例#5
0
 /// <summary>
 /// Creates a new instance of <see cref="JsonPropertyDefinition"/>.
 /// </summary>
 /// <param name="propertyName">The name of the property.</param>
 /// <param name="category">A category the property belongs.</param>
 /// <param name="description">A description of the property.</param>
 /// <param name="defaultValue">The default value if the property.</param>
 /// <param name="browsable">Can the property be viewed in a control such as PropertyGrid.</param>
 /// <param name="readOnly">Can the property be edited?</param>
 public static JsonPropertyDefinition Create(string propertyName, string category, string description, JsonValue defaultValue, bool browsable, bool readOnly)
 {
     return new JsonPropertyDefinition(propertyName, category, description, defaultValue, browsable, readOnly);
 }