Catel.MVVM.ManagedViewModel.NotifyViewModelsOfEvent C# (CSharp) Method

NotifyViewModelsOfEvent() private method

Notifies all interested view models of an event that took place.
The is null. The is null.
private NotifyViewModelsOfEvent ( IViewModel viewModel, ViewModelEvent viewModelEvent, EventArgs e ) : void
viewModel IViewModel The view model.
viewModelEvent ViewModelEvent The view model event.
e System.EventArgs The instance containing the event data.
return void
        private void NotifyViewModelsOfEvent(IViewModel viewModel, ViewModelEvent viewModelEvent, EventArgs e)
        {
            Argument.IsNotNull("viewModel", viewModel);
            Argument.IsNotNull("e", e);

            lock (_lock)
            {
                var viewModels = (from viewModelKeyValuePair in _interestedViewModels
                                  select viewModelKeyValuePair.Value).ToList();

                foreach (var vm in viewModels)
                {
                    try
                    {
                        var notifyableViewModel = vm as INotifyableViewModel;
                        if (notifyableViewModel != null)
                        {
                            notifyableViewModel.ViewModelEvent(viewModel, viewModelEvent, e);
                        }
                    }
                    catch (Exception ex)
                    {
                        Log.Error(ex, "Failed to let an interested view model know that a view model has changed. Probably the view model is not correctly cleaned up");
                    }
                }
            }
        }
        #endregion