Пример #1
0
 /// <summary>
 /// Creates a new instance.
 /// </summary>
 /// <param name="validationDispatcher">A validation dispatcher used for validating commands.</param>
 /// <param name="innerDispatcher">An inner (real) commands dispatcher for validated commands handling.</param>
 public ValidationCommandDispatcher(IValidationDispatcher validationDispatcher, ICommandDispatcher innerDispatcher)
 {
     Ensure.NotNull(validationDispatcher, "validationDispatcher");
     Ensure.NotNull(innerDispatcher, "innerDispatcher");
     this.validationDispatcher = validationDispatcher;
     this.innerDispatcher      = innerDispatcher;
 }
 public ViewModelFacade(ITranslationService translationService, IValidationDispatcher validationDispatcher, INavigationService navigationService, ICommandDispatcher commandDispatcher, INoteMeClientMapper mapper, IQueryDispatcher queryDispatcher, IDialogService dialogService)
 {
     TranslationService   = translationService;
     ValidationDispatcher = validationDispatcher;
     NavigationService    = navigationService;
     CommandDispatcher    = commandDispatcher;
     Mapper          = mapper;
     QueryDispatcher = queryDispatcher;
     DialogService   = dialogService;
 }
Пример #3
0
 /// <summary>
 /// Validates <paramref name="model"/> synchronously using runtime type of model.
 /// Best for framework code where TModel can't be determined.
 /// </summary>
 /// <typeparam name="TModel">Type of model to validate.</typeparam>
 /// <param name="dispatcher">A validation dispatcher.</param>
 /// <param name="model">An instance to validate.</param>
 /// <returns><see cref="IValidationResult"/> describing success or validation failure.</returns>
 public static IValidationResult Validate(this IValidationDispatcher dispatcher, object model)
 {
     try
     {
         Task <IValidationResult> task = dispatcher.ValidateAsync(model);
         task.Wait();
         return(task.Result);
     }
     catch (AggregateException e)
     {
         throw e.InnerException;
     }
 }