private void _attributes_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) { if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Add) { var attributes = new Collection <MetaAttribute>(); foreach (MetaAttribute attribute in e.NewItems) { attributes.Add(attribute); } var args = new TestAttributesCommandArgs(attributes); TestCommandsSource.RaiseOnAddTestAttributes(_commandsSource, _testContext, args); } else if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Remove) { var attributes = new Collection <MetaAttribute>(); foreach (MetaAttribute attribute in e.OldItems) { attributes.Add(attribute); } var args = new TestAttributesCommandArgs(attributes); TestCommandsSource.RaiseOnRemoveTestAttributes(_commandsSource, _testContext, args); } }
public MetaAttributesCollection(ITestContext testContext, TestCommandsSource commandsSource) { _testContext = testContext; _commandsSource = commandsSource; var commandArgs = new TestAttributesCommandArgs(null); TestCommandsSource.RaiseOnGetTestAttributes(_commandsSource, _testContext, commandArgs); _attributes = new ObservableCollection <MetaAttribute>(commandArgs.Attributes); _attributes.CollectionChanged += _attributes_CollectionChanged; }
public static void RaiseOnRemoveTestAttributes(TestCommandsSource commandsSource, ITestContext testContext, TestAttributesCommandArgs args) { commandsSource.OnRemoveTestAttributes?.Invoke(testContext, args); }