示例#1
0
        /// <summary>
        /// Sets the item at the given index
        /// </summary>
        /// <param name="index">The index.</param>
        /// <param name="value">The item.</param>
        protected void SetValueAt(int index, T value)
        {
            this.EnsureNotDisposed();
            //Recuperiamo un riferimento al valore che verrà sovrascritto
            T oldValue = this.GetValueAt(index);

            SetValueAtEventArgs <T> args = new SetValueAtEventArgs <T>(index, value, oldValue);

            this.OnSetValueAt(args);

            if (!args.Cancel)
            {
                //Ci sganciamo da quello attualmente presente nella collection
                this.UnwireListItem(oldValue);
                if (!this.Contains(value))
                {
                    //Ci leghiamo a quello in arrivo
                    this.WireListItem(value);
                }

                //Impostiamo il valore
                this.Storage[index] = value;

                this.OnSetValueAtCompleted(index, value, oldValue);
                this.OnCollectionChanged(new CollectionChangedEventArgs <T>(CollectionChangeType.ItemReplaced, index, index, oldValue));
            }
        }
示例#2
0
 /// <summary>
 /// Called just before the set operation.
 /// </summary>
 /// <param name="e">The <see cref="Radical.Model.SetValueAtEventArgs&lt;T&gt;"/> instance containing the event data.</param>
 protected virtual void OnSetValueAt(SetValueAtEventArgs <T> e)
 {
     this.EnsureNotDisposed();
 }