Exemple #1
0
        private void Update(object newValue, Index index, bool sendNotification)
        {
            if (index == Index.Empty)
            {
                throw new ArgumentException("index cannot be empty.");
            }
            var oldValue = Retrieve(index);
            ItemChangeEventArgs itemArgs = null;

            if (sendNotification)
            {
                itemArgs = new ItemChangeEventArgs(this, index, ContentChangeType.CollectionUpdate, oldValue, newValue);
                NotifyItemChanging(itemArgs);
            }
            var collectionDescriptor = Descriptor as CollectionDescriptor;
            var dictionaryDescriptor = Descriptor as DictionaryDescriptor;

            if (collectionDescriptor != null)
            {
                collectionDescriptor.SetValue(Value, index.Int, newValue);
            }
            else if (dictionaryDescriptor != null)
            {
                dictionaryDescriptor.SetValue(Value, index.Value, newValue);
            }
            else
            {
                throw new NotSupportedException("Unable to set the node value, the collection is unsupported");
            }

            UpdateReferences();
            if (sendNotification)
            {
                NotifyItemChanged(itemArgs);
            }
        }
Exemple #2
0
 protected void NotifyItemChanged(ItemChangeEventArgs args)
 {
     ItemChanged?.Invoke(this, args);
     FinalizeChange?.Invoke(this, args);
 }
Exemple #3
0
 protected void NotifyItemChanging(ItemChangeEventArgs args)
 {
     PrepareChange?.Invoke(this, args);
     ItemChanging?.Invoke(this, args);
 }
Exemple #4
0
 private void OnItemChanged(object sender, ItemChangeEventArgs e)
 {
     ItemChanged?.Invoke(sender, e);
 }