コード例 #1
0
        public override bool Apply()
        {
            ModelItem oldValue = this.Dictionary[this.Key];

            if ((oldValue == null && this.NewValue == null) ||
                (oldValue != null && this.NewValue != null && oldValue.GetCurrentValue().Equals(this.NewValue.GetCurrentValue())))
            {
                return(false);
            }

            ((ModelItemDictionaryImpl)this.Dictionary).EditCore(this.Key, this.NewValue);

            ModelChangeInfo changeInfo = ModelChangeInfoImpl.CreateDictionaryValueChanged(this.Dictionary, this.Key, this.OldValue, this.NewValue);

            if (this.OldValue != null)
            {
                this.ModelTreeManager.modelService.OnModelItemRemoved(this.OldValue, changeInfo);
                changeInfo = null;
            }
            if (this.NewValue != null)
            {
                this.ModelTreeManager.modelService.OnModelItemAdded(this.NewValue, changeInfo);
            }
            return(true);
        }
コード例 #2
0
        public override bool Apply()
        {
            Fx.Assert(this.ModelTreeManager != null, "Modeltreemanager cannot be null");
            Fx.Assert(this.Owner != null, "Owner modelitem cannot be null");
            Fx.Assert(!String.IsNullOrEmpty(this.PropertyName), " property name cannot be null or emptry");
            ModelPropertyImpl dataModelProperty = (ModelPropertyImpl)this.Owner.Properties[this.PropertyName];
            ModelItem         oldValue          = dataModelProperty.Value;

            if ((oldValue == null && this.NewValue == null) ||
                (oldValue != null && this.NewValue != null && oldValue.GetCurrentValue().Equals(this.NewValue.GetCurrentValue())))
            {
                return(false);
            }
            dataModelProperty.SetValueCore(this.NewValue);
            ModelChangeInfo changeInfo = ModelChangeInfoImpl.CreatePropertyChanged(this.Owner, this.PropertyName, this.OldValue, this.NewValue);

            this.ModelTreeManager.NotifyPropertyChange(dataModelProperty, changeInfo);
            return(true);
        }
コード例 #3
0
        private void ApplyInsert()
        {
            Fx.Assert(this.ModelTreeManager != null, "ModelTreeManager cannot be null.");
            Fx.Assert(this.Collection != null, "this.Collection cannot be null.");

            if (this.Index >= 0)
            {
                ((ModelItemCollectionImpl)this.Collection).InsertCore(this.Index, this.Item);
            }
            else
            {
                Fx.Assert(this.Index == -1, "-1 must be used to indicate Add(item)");
                this.Index = this.Collection.Count;
                ((ModelItemCollectionImpl)this.Collection).AddCore(this.Item);
            }

            ModelChangeInfo changeInfo = ModelChangeInfoImpl.CreateCollectionItemAdded(this.Collection, this.Item);

            this.ModelTreeManager.NotifyCollectionInsert(this.Item, changeInfo);
        }
コード例 #4
0
        private void ApplyDelete()
        {
            Fx.Assert(this.ModelTreeManager != null, "ModelTreeManager cannot be null.");
            Fx.Assert(this.Collection != null, "this.Collection cannot be null.");

            if (this.Index >= 0)
            {
                ((ModelItemCollectionImpl)this.Collection).RemoveAtCore(this.Index);
            }
            else
            {
                Fx.Assert(this.Index == -1, "-1 must be used to indicate Remove(item)");
                this.Index = this.Collection.IndexOf(this.Item);
                ((ModelItemCollectionImpl)this.Collection).RemoveCore(this.Item);
            }

            ModelChangeInfo changeInfo = ModelChangeInfoImpl.CreateCollectionItemRemoved(this.Collection, this.Item);

            this.ModelTreeManager.NotifyCollectionRemove(this.Item, changeInfo);
        }
コード例 #5
0
ファイル: DictionaryChange.cs プロジェクト: dox0/DotNet471RS3
        private void ApplyInsert()
        {
            ((ModelItemDictionaryImpl)this.Dictionary).AddCore(this.Key, this.Value);

            ModelChangeInfo changeInfo = ModelChangeInfoImpl.CreateDictionaryKeyValueAdded(this.Dictionary, this.Key, this.Value);

            if (this.Key != null)
            {
                this.ModelTreeManager.modelService.OnModelItemAdded(this.Key, changeInfo);
                changeInfo = null;
            }

            if (this.Value != null)
            {
                this.ModelTreeManager.modelService.OnModelItemAdded(this.Value, changeInfo);
                changeInfo = null;
            }

            if (changeInfo != null)
            {
                this.ModelTreeManager.modelService.EmitModelChangeInfo(changeInfo);
            }
        }