Beispiel #1
0
        /// <summary>
        /// Creates a <see cref="MoBack.MoBackRow"/> object that encapsulates the provided MoBackObject (e.g. for saving an object to a table as a new row).
        /// </summary>
        /// <param name="tableName">Table the row should be associated with.</param>
        /// <param name="data">MoBackObject to encapsulate.</param>
        public MoBackRow(string tableName, MoBackObject data)
        {
            MoBackRow objectAsRow = new MoBackRow();

            objectAsRow.TableName = tableName;
            objectAsRow.ShallowCopy(data);
        }
Beispiel #2
0
        /// <summary>
        /// Converts a JSON object to a MobackObject.
        /// </summary>
        /// <returns> A MoBackObject. </returns>
        /// <param name="jsonObject"> A JSON object. </param>
        public static MoBackObject FromJSON(SimpleJSONClass jsonObject)
        {
            MoBackObject mObject = new MoBackObject();

            ProcessJsonIntoMoBackObject(mObject, jsonObject);
            return(mObject);
        }
Beispiel #3
0
 /// <summary>
 /// Set the specified index and value.
 /// </summary>
 /// <param name="index"> An index value. </param>
 /// <param name="value"> A MoBackObject value. </param>
 public void Set(int index, MoBackObject value)
 {
     if (ValidateIndex(index))
     {
         objects[index]     = value;
         objectTypes[index] = MoBackValueType.MoBackObject;
     }
     else
     {
         Debug.LogError("Error: Index is out of range.");
     }
 }
Beispiel #4
0
        /// <summary>
        /// Processes a JSON object into a MoBackObject.
        /// </summary>
        /// <param name="mObject"> A MoBackObject to process. </param>
        /// <param name="jsonObject"> A JSON object. </param>
        protected static void ProcessJsonIntoMoBackObject(MoBackObject mObject, SimpleJSONClass jsonObject)
        {
            foreach (KeyValuePair <string, SimpleJSONNode> entry in jsonObject.dict)
            {
                // These 2 values are in Relation array values when RetrieveRelation with ?include={ColumnName}
                // key == success is for BatchProcessing, after saving/updating, success is auto generated and return in json.
                if (entry.Key == "__type" || entry.Key == "className" || entry.Key == "success")
                {
                    continue;
                }

                MoBackValueType moBackType;
                object          data = MoBackUtils.MoBackTypedObjectFromJSON(entry.Value, out moBackType);

                // This should always be equivalent to calling SetValue() with the appropriate type; if SetValue() functions are refactored then so too should this, and vice-versa.
                mObject.SetColumnType(entry.Key, moBackType);
                mObject.storeValues[entry.Key] = data;
            }
        }
Beispiel #5
0
 /// <summary>
 /// Completes a shallow copy of elements in a MoBackObject.
 /// </summary>
 /// <param name="copyFrom"> The MoBackObject to copy from. </param>
 protected void ShallowCopy(MoBackObject copyFrom)
 {
     storeValues    = copyFrom.storeValues;
     columnTypeData = copyFrom.columnTypeData;
     columnTypeDataAsColumnDefinitions = copyFrom.columnTypeDataAsColumnDefinitions;
 }
Beispiel #6
0
 /// <summary>
 /// Sets the value with a MoBackObject element at the specified key.
 /// </summary>
 /// <param name="key"> The key to be set. </param>
 /// <param name="value"> The value to set. </param>
 public void SetValue(string key, MoBackObject value)
 {
     storeValues[key] = value;
     SetColumnType(key, MoBackValueType.MoBackObject);
 }
Beispiel #7
0
 /// <summary>
 /// Adds a MoBackObject type object to the container.
 /// </summary>
 /// <param name="value"> A MoBackObject value. </param>
 public void Add(MoBackObject value)
 {
     objects.Add(value);
     objectTypes.Add(MoBackValueType.MoBackObject);
 }