private static void OnViewModelClosed(object sender, EventArgs e) { var viewModel = (IViewModel)sender; AuditingManager.OnViewModelClosed(viewModel); UnsubscribeEvents(viewModel); }
/// <summary> /// Registers the view model to the <see cref="AuditingManager"/>. /// <para /> /// This helper will automatically unsubscribe from all events when the view model is closed. /// </summary> /// <param name="viewModel">The view model to register.</param> /// <remarks> /// This helper will call the <see cref="AuditingManager.OnViewModelCreating"/> and <see cref="AuditingManager.OnViewModelCreated"/> /// automatically. /// </remarks> /// <exception cref="ArgumentNullException">The <paramref name="viewModel" /> is <c>null</c>.</exception> public static void RegisterViewModel(IViewModel viewModel) { Argument.IsNotNull("viewModel", viewModel); AuditingManager.OnViewModelCreating(viewModel.GetType()); SubscribeEvents(viewModel); AuditingManager.OnViewModelCreated(viewModel.GetType()); }
private static Task OnViewModelClosingAsync(object sender, EventArgs e) { if (!AuditingManager.IsAuditingEnabled) { return(TaskHelper.Completed); } AuditingManager.OnViewModelClosing((IViewModel)sender); return(TaskHelper.Completed); }
private static Task OnViewModelCommandExecutedAsync(object sender, CommandExecutedEventArgs e) { if (!AuditingManager.IsAuditingEnabled) { return(TaskHelper.Completed); } AuditingManager.OnCommandExecuted((IViewModel)sender, e.CommandPropertyName, e.Command, e.CommandParameter); return(TaskHelper.Completed); }
private static void OnViewModelPropertyChanging(object sender, PropertyChangingEventArgs e) { var viewModel = (IViewModel)sender; object propertyValue = null; if (!string.IsNullOrEmpty(e.PropertyName)) { PropertyHelper.TryGetPropertyValue(viewModel, e.PropertyName, out propertyValue); } AuditingManager.OnPropertyChanging(viewModel, e.PropertyName, propertyValue); }
private static Task OnViewModelClosedAsync(object sender, EventArgs e) { if (!AuditingManager.IsAuditingEnabled) { return(TaskHelper.Completed); } var viewModel = (IViewModel)sender; AuditingManager.OnViewModelClosed(viewModel); UnsubscribeEvents(viewModel); return(TaskHelper.Completed); }
/// <summary> /// Registers the view model to the <see cref="AuditingManager"/>. /// <para /> /// This helper will automatically unsubscribe from all events when the view model is closed. /// </summary> /// <param name="viewModel">The view model to register.</param> /// <remarks> /// This helper will call the <see cref="AuditingManager.OnViewModelCreating"/> and <see cref="AuditingManager.OnViewModelCreated"/> /// automatically. /// </remarks> /// <exception cref="ArgumentNullException">The <paramref name="viewModel" /> is <c>null</c>.</exception> public static void RegisterViewModel(IViewModel viewModel) { Argument.IsNotNull("viewModel", viewModel); var isAuditingEnabled = AuditingManager.IsAuditingEnabled; if (isAuditingEnabled) { AuditingManager.OnViewModelCreating(viewModel.GetType()); } SubscribeEvents(viewModel); if (isAuditingEnabled) { AuditingManager.OnViewModelCreated(viewModel); } }
private static void OnViewModelPropertyChanged(object sender, PropertyChangedEventArgs e) { if (!AuditingManager.IsAuditingEnabled) { return; } var viewModel = (IViewModel)sender; object propertyValue = null; if (!string.IsNullOrEmpty(e.PropertyName) && !KnownIgnoredPropertyNames.Contains(e.PropertyName)) { PropertyHelper.TryGetPropertyValue(viewModel, e.PropertyName, out propertyValue); } AuditingManager.OnPropertyChanged(viewModel, e.PropertyName, propertyValue); }
private static void OnViewModelClosing(object sender, EventArgs e) { AuditingManager.OnViewModelClosing((IViewModel)sender); }
private static void OnViewModelCommandExecuted(object sender, CommandExecutedEventArgs e) { AuditingManager.OnCommandExecuted((IViewModel)sender, e.CommandPropertyName, e.Command, e.CommandParameter); }