public ConditionsEditorHistoryHandler(ConditionsEditorViewModel viewModel, IConditionsFactory conditionsFactory) { this.conditionsFactory = conditionsFactory; conditionsSub = viewModel.Conditions.ToStream().SubscribeAction(a => { if (a.Type == CollectionEventType.Add) { foreach (var val in a.Item.Values()) { val.OnValueChanged += OnChanged; } a.Item.ConditionChanged += OnConditionChanged; PushAction(new ConditionAddedAction(viewModel, a.Item, a.Index)); } else { a.Item.ConditionChanged -= OnConditionChanged; foreach (var val in a.Item.Values()) { val.OnValueChanged -= OnChanged; } PushAction(new ConditionRemovedAction(viewModel, a.Item, a.Index)); } }); }
public ConditionAddedAction(ConditionsEditorViewModel vm, ConditionViewModel condition, int index) { this.vm = vm; this.condition = condition; this.index = index; }