Exemple #1
0
        internal string Add(object value)
        {
            if (innerDictionary.ContainsValue(value))
            {
                return(GetKey(value));
            }
            string key = client.Post("objects");

            value = new Dynamic.ExpandibleObject(value);
            Set(key, value);
            Dictionary <string, object> upd = new Dictionary <string, object>();

            if (value == null)
            {
                upd["/" + key + "/type/"]  = "null";
                upd["/" + key + "/value/"] = null;
            }
            else if (!isPrimitive(value))
            {
                UpdateFields(value, getFields(value));
            }
            else
            {
                var type = sanitizeTypeName(value.GetType());
                upd["/" + key + "/type/"] = type;
                var basePath = "/" + key + "/";
                //first of all i need to see if the value is either null or undefined.
                if (type == "Date")
                {
                    upd[basePath + "value"] = ((DateTime)value).ToUniversalTime().ToString("s");
                }
                else
                {
                    upd[basePath + "value"] = value;
                }
            }


            client.Patch("objects", upd);
            return(key);
        }
Exemple #2
0
 public ExpandibleObjectDictionary(ExpandibleObject InnerObject)
 {
     innerObject = InnerObject;
 }