Ejemplo n.º 1
0
        /// <summary>
        /// MoBack JSON from relation. Of dubious usefulness because uploading and updating relations directly is presently forbidden.
        /// </summary>
        /// <returns>The moback JSON representing the relation.</returns>
        /// <param name="relation">Relation.</param>
        public static SimpleJSONNode MoBackJSONFromRelation(MoBackRelation relation)
        {
            SimpleJSONClass relationJSON = new SimpleJSONClass();

            relationJSON ["__type"] = "Pointer";

            SimpleJSONArray pointersJSON = new SimpleJSONArray();

            for (int i = 0; i < relation._pointers.Count; i++)
            {
                pointersJSON.Add(MoBackPointer.PointerToMoBackJSON(relation._pointers[i]));
            }
            relationJSON ["value"] = pointersJSON;

            return(relationJSON);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Gets JSON the server expects for an remove relation operation, that removes the supplied list of pointers to some relation.
        /// </summary>
        /// <returns>The remove operation as mo back JSO.</returns>
        /// <param name="pointersToRemove">Pointers to add.</param>
        public static SimpleJSONClass RelationRemoveOpAsMoBackJSON(MoBackPointer[] pointersToRemove)
        {
            SimpleJSONClass relationOpJsonStructure = new SimpleJSONClass();

            relationOpJsonStructure ["__op"] = "removeRelation";

            SimpleJSONArray pointers = new SimpleJSONArray();

            for (int i = 0; i < pointersToRemove.Length; i++)
            {
                pointers.Add(MoBackPointer.PointerToMoBackJSON(pointersToRemove[i]));
            }
            relationOpJsonStructure ["objects"] = pointers;

            return(relationOpJsonStructure);
        }