/// <summary> /// Cleans up when this instance of FnsPreprocessor is no longer required. /// </summary> /// <param name="disposing">True if this object is being disposed.</param> /// <remarks>Required because _messageProcessor is a static member and during test cases, we cannot guarantee /// when the finalizer will run. An explicit call to Dispose() at the end of each test ensures that we start /// each new test with a clean object.</remarks> protected virtual void Dispose(bool disposing) { if (!_disposed) { if (disposing) { foreach (ControlViewModel controlViewModel in this) { controlViewModel.ValueChangeCompleted += new EventHandler <ValueChangeCompletedEventArgs>(ControlValueChangeCompleted); controlViewModel.ValidationStateChanged += new EventHandler <ValidationStateChangedEventArgs>(ControlValidationStateChanged); } (_strategyEdits as IDisposable).Dispose(); _strategyEdits = null; } _disposed = true; } }
/// <summary> /// Initializes a new <see cref="ViewModelControlCollection"/> /// </summary> /// <param name="strategy">Strategy that the underlying controls belong to.</param> /// <param name="mode">Data entry mode.</param> public ViewModelControlCollection(Strategy_t strategy, IInitialFixValueProvider initialValueProvider) { foreach (Control_t control in strategy.Controls) { ControlViewModel controlViewModel = ControlViewModel.Create(strategy, control, initialValueProvider); Add(controlViewModel); controlViewModel.ValueChangeCompleted += new EventHandler <ValueChangeCompletedEventArgs>(ControlValueChangeCompleted); controlViewModel.ValidationStateChanged += new EventHandler <ValidationStateChangedEventArgs>(ControlValidationStateChanged); // Special treatment for radio buttons under Framework 3.5 #if !NET462 if (control is RadioButton_t) { RegisterRadioButton(control as RadioButton_t, controlViewModel as RadioButtonViewModel); } #endif } _strategyEdits = new ViewModelStrategyEditCollection(strategy.StrategyEdits, this); BindStateRules(); }