예제 #1
0
        /// <summary>
        ///     Gets or sets the <see cref="TEntity" /> with the specified index.
        /// </summary>
        public TEntity this[int index]
        {
            get
            {
                /////
                // Struct type always returns an instance.
                /////
                IMutableIdKey match = _tracker.ElementAt(index);

                return(Entity.Get <TEntity>(match.Key));
            }
            set
            {
                Precheck( );

                /////
                // Struct type always returns an instance.
                /////
                IMutableIdKey match = _tracker.ElementAt(index);

                _tracker.Remove(match);

                if (value != null)
                {
                    _tracker.Add((( IEntityInternal )value).MutableId);
                }
            }
        }
예제 #2
0
        protected override async Task ExecuteAsync(IKey key, CancellationToken cancellationToken)
        {
            Movie model = collection.FindByKey(key);

            if (model != null && await navigator.ConfirmAsync($"Delete movie '{model.Name}'?"))
            {
                changeTracker.Remove(collection, model);
            }
        }
예제 #3
0
        /// <summary>
        ///     Removes the specified item.
        /// </summary>
        /// <param name="item">The item.</param>
        /// <returns></returns>
        public bool Remove(TEntity item)
        {
            if (item == null)
            {
                return(false);
            }

            Precheck( );

            IMutableIdKey[] matches = _tracker.Where(pair => pair.Key == item.Id).ToArray( );

            return(matches.Aggregate(false, (current, match) => current & _tracker.Remove(match)));
        }