コード例 #1
0
 public void Attr(string name, JSONObject value)
 {
     if (JSONProperties.Keys.Contains(name))
     {
         JSONProperties[name] = value;
     }
     else
     {
         JSONProperties.Add(name, value);
     }
 }
コード例 #2
0
 public void Attr(string name, object value)
 {
     if (JSONProperties.Keys.Contains(name))
     {
         JSONProperties[name] = new JSONObject()
         {
             Value = value
         };
     }
     else
     {
         JSONProperties.Add(name, new JSONObject()
         {
             Value = value
         });
     }
 }
コード例 #3
0
 public JSONObject(object jsonProperties)
 {
     if (jsonProperties == null)
     {
         this.Value = null;
     }
     else if (jsonProperties as JSONObjectBase != null)
     {
         //MergeWithJSONObject((JSONObjectBase)jsonProperties);
         _InnerObject = (JSONObjectBase)jsonProperties;
     }
     else if (jsonProperties.GetType() == typeof(string))
     {
         Value = jsonProperties;
     }
     else
     {
         foreach (PropertyInfo pi in jsonProperties.GetType().GetProperties())
         {
             object o = pi.GetValue(jsonProperties, null);
             if (o != null)
             {
                 if (o.GetType().IsSubclassOf(typeof(JSONObjectBase)))
                 {
                     JSONProperties.Add(pi.Name, (JSONObjectBase)o);
                 }
                 else
                 {
                     JSONProperties.Add(pi.Name, new JSONObject()
                     {
                         Value = o
                     });
                 }
             }
             else
             {
                 JSONProperties.Add(pi.Name, new JSONObject()
                 {
                     Value = null
                 });
             }
         }
     }
 }
コード例 #4
0
 public virtual JSONObjectBase MergeObjectProperties <T>(Dictionary <string, T> jsonProperties)
 {
     if (jsonProperties == null)
     {
         return(this);
     }
     if (jsonProperties.Count < 1)
     {
         return(this);
     }
     foreach (KeyValuePair <string, T> kvp in jsonProperties)
     {
         if (JSONProperties.ContainsKey(kvp.Key.ToLower()))
         {
             JSONProperties[kvp.Key.ToLower()] = new JSONObject(jsonProperties[kvp.Key]);
         }
         else
         {
             JSONProperties.Add(kvp.Key.ToLower(), new JSONObject(jsonProperties[kvp.Key]));
         }
     }
     return(this);
 }