예제 #1
0
        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);
            }
        }
예제 #2
0
 private void OnItemChanged(object sender, ItemChangeEventArgs e)
 {
     ItemChanged?.Invoke(sender, e);
 }
예제 #3
0
 protected void NotifyItemChanged(ItemChangeEventArgs args)
 {
     ItemChanged?.Invoke(this, args);
     FinalizeChange?.Invoke(this, args);
 }
예제 #4
0
 protected void NotifyItemChanging(ItemChangeEventArgs args)
 {
     PrepareChange?.Invoke(this, args);
     ItemChanging?.Invoke(this, args);
 }