Exemple #1
0
        private void getValueResponse(JSON root)
        {
            var    keys         = root.fields.Keys;
            string propertyname = "";

            foreach (string key in keys)
            {
                propertyname = key;
                break;
            }

            Debug.Log("propertyname:" + propertyname);

            if (propertyname == "")
            {
                Debug.Log("No property on server!");
                return;
            }

            PropertyInfo propertyInfo = this.GetType().GetProperty(propertyname);

            if (propertyInfo != null)
            {
                ColibrySerializeHelper.setProperty(this, propertyInfo, root, propertyname);
            }
            else
            {
                Debug.Log("No such property " + propertyname);
            }
        }
Exemple #2
0
        private JSON getFieldsValuesJsonObject()
        {
            JSON root = new JSON();

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

            foreach (var p in properties)
            {
                ColibrySerializeHelper.getProperty(this, p, root, p.Name);
            }
            return(root);
        }
Exemple #3
0
 private void loadUserResponse(JSON root)
 {
     //root=getFieldsValuesJsonObject();
     //Debug.Log (root.serialized);
     //set data back to instance
     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);
         }
     }
 }
Exemple #4
0
 // JSON to class conversion
 virtual public 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 #5
0
        // serialize this class to JSON
        virtual public 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);
        }
Exemple #6
0
        public JSON unsetValue(string fieldname)
        {
            var propertyInfo = this.GetType().GetProperty(fieldname);

            if (propertyInfo != null)
            {
                propertyInfo.SetValue(this, null, null);
                JSON root       = new JSON();
                JSON roottosend = new JSON();

                ColibrySerializeHelper.getProperty(this, propertyInfo, root, propertyInfo.Name);
                roottosend["field"] = fieldname;
                roottosend["value"] = root[propertyInfo.Name];
                return(roottosend);
            }
            else
            {
                Debug.Log("No such property " + fieldname);
                return(null);
            }
        }
Exemple #7
0
        public void setValue(SDKCorePluginCustomCallbackDelegate fp, string fieldname, object fieldvalue)
        {
            var propertyInfo = this.GetType().GetProperty(fieldname);

            if (propertyInfo != null)
            {
                propertyInfo.SetValue(this, fieldvalue, null);
                JSON root       = new JSON();
                JSON roottosend = new JSON();

                ColibrySerializeHelper.getProperty(this, propertyInfo, root, propertyInfo.Name);
                roottosend["field"] = fieldname;
                roottosend["value"] = root[propertyInfo.Name];

                string stringToSend = roottosend.serialized;
                SDKCorePlugin.SDKCorePluginSendRequest(ColibryUserRequestSigns.SET_VALUE, ColibryUserCmds.SET_VALUE, stringToSend, sdkResponse, fp);
            }
            else
            {
                Debug.Log("No such property " + fieldname);
            }
        }