private void Update(object newValue, NodeIndex index, bool sendNotification) { if (index == NodeIndex.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, ConvertValue(newValue, collectionDescriptor.ElementType)); } else if (dictionaryDescriptor != null) { dictionaryDescriptor.SetValue(Value, index.Value, ConvertValue(newValue, dictionaryDescriptor.ValueType)); } else { throw new NotSupportedException("Unable to set the node value, the collection is unsupported"); } UpdateReferences(); if (sendNotification) { NotifyItemChanged(itemArgs); } }
private void OnItemChanged(object sender, ItemChangeEventArgs e) { ItemChanged?.Invoke(sender, e); }
protected void NotifyItemChanged(ItemChangeEventArgs args) { ItemChanged?.Invoke(this, args); FinalizeChange?.Invoke(this, args); }
protected void NotifyItemChanging(ItemChangeEventArgs args) { PrepareChange?.Invoke(this, args); ItemChanging?.Invoke(this, args); }