コード例 #1
0
 private void ManageObjectIfNeeded(T obj)
 {
     if (!obj.IsManaged)
     {
         _realm.Manage(obj);
     }
 }
コード例 #2
0
 public static void SetObject(Realm realm, TableHandle table, IntPtr columnIndex, IntPtr rowIndex, RealmObject @object)
 {
     if (@object == null)
     {
         NativeTable.ClearLink(table, columnIndex, rowIndex);
     }
     else
     {
         if ([email protected])
         {
             realm.Manage(@object);
         }
         NativeTable.SetLink(table, columnIndex, rowIndex, @object.RowHandle.RowIndex);
     }
 }
コード例 #3
0
        // Originally a generic fallback, now used only for RealmObject To-One relationship properties
        // most other properties handled with woven type-specific setters above
        protected void SetObjectValue <T>(string propertyName, T value) where T : RealmObject
        {
            Debug.Assert(_realm != null, "Object is not managed, but managed access was attempted");

            if (!_realm.IsInTransaction)
            {
                throw new RealmOutsideTransactionException("Cannot set values outside transaction");
            }

            var rowIndex = _rowHandle.RowIndex;

            if (value == null)
            {
                NativeTable.ClearLink(_metadata.Table, _metadata.ColumnIndices[propertyName], rowIndex);
            }
            else
            {
                if (!value.IsManaged)
                {
                    _realm.Manage(value);
                }
                NativeTable.SetLink(_metadata.Table, _metadata.ColumnIndices[propertyName], rowIndex, value.RowHandle.RowIndex);
            }
        }