Exemple #1
0
 // JSON to class conversion
 public override ColibrySerializeHelperCustomClass JSONtoMyClass(JSON root)
 {
     checked
     {
         PropertyInfo[] properties = this.GetType().GetProperties();
         foreach (PropertyInfo p in properties)
         {
             string name = p.Name;
             if (root.fields.ContainsKey(name))
             {
                 ColibrySerializeHelper.setProperty(this, p, root, name);
             }
         }
         return(this);
     }
 }
Exemple #2
0
    // serialize this class to JSON
    public override JSON ToJSON()
    {
        JSON root = new JSON();

        PropertyInfo[] properties = this.GetType().GetProperties();

        foreach (var p in properties)
        {
            if (p.Name == "id")
            {
                if (id == null)
                {
                    continue;
                }
            }
            ColibrySerializeHelper.getProperty(this, p, root, p.Name);
        }
        return(root);
    }