Example #1
0
        /// <summary>
        /// Makes a relationship to an item, inserting at a specified location ahead of whatever else was in that location.
        /// </summary>
        /// <param name="index">Ordinal zero-based index at which to insert the related items.</param>
        /// <param name="item">RealmObject being inserted into the relationship.</param>
        /// <exception cref="ArgumentOutOfRangeException">When the index is out of range for the related items.</exception>
        public void Insert(int index, T item)
        {
            if (index < 0)
            {
                throw new ArgumentOutOfRangeException();
            }

            this.AddObjectToRealmIfNeeded(item);
            _listHandle.Insert((IntPtr)index, item.ObjectHandle);
        }
Example #2
0
        /// <summary>
        /// Makes a relationship to an item, inserting at a specified location ahead of whatever else was in that location.
        /// </summary>
        /// <param name="index">Ordinal zero-based index at which to insert the related items.</param>
        /// <param name="item">RealmObject being inserted into the relationship.</param>
        /// <typeparam name="T">Type of the RealmObject which is the target of the relationship.</typeparam>
        /// <exception cref="ArgumentOutOfRangeException">When the index is out of range for the related items.</exception>
        public void Insert(int index, T item)
        {
            if (index < 0)
            {
                throw new ArgumentOutOfRangeException();
            }

            this.ManageObjectIfNeeded(item);
            var rowIndex = ((RealmObject)item).RowHandle.RowIndex;

            _listHandle.Insert((IntPtr)index, rowIndex);
        }