예제 #1
0
 protected ModelWithValidationAsync(IDispatcherSchedulerProvider scheduler, IValidationAsync <TModel, TValidator> validation)
 {
     Validation = validation;
     Validation.Initialise((TModel)this);
     Validation.ErrorsChanged
     .ObserveOn(scheduler.Dispatcher.RX)
     .Subscribe(x => ErrorsChanged.SafeInvoke(this, new DataErrorsChangedEventArgs(x)))
     .AddDisposable(Disposables);
 }
예제 #2
0
        public QuoteModel(IDispatcherSchedulerProvider scheduler, IValidationAsync <QuoteModel, QuoteValidator> validation)
            : base(scheduler, validation)
        {
            _instrument.ConnectINPCProperty(this, () => Instrument, scheduler).AddDisposable(Disposables);
            _instrument.AddValidation(validation, scheduler, () => Instrument).AddDisposable(Disposables);

            _notes.ConnectINPCProperty(this, () => Notes, scheduler).AddDisposable(Disposables);
            _notes.AddValidation(validation, scheduler, () => Notes).AddDisposable(Disposables);
        }
예제 #3
0
 public static IDisposable AddValidation <T, TModel, TValidation, TProperty>(this ObservableProperty <T> observableProperty,
                                                                             IValidationAsync <TModel, TValidation> validation,
                                                                             IDispatcherSchedulerProvider scheduler,
                                                                             Expression <Func <TProperty> > propertyExpression)
     where TModel : ISupportValidationAsync <TModel, TValidation>
     where TValidation : AbstractValidator <TModel>, new()
 {
     return(observableProperty.ValueChanged
            .ObserveOn(scheduler.Dispatcher.RX)
            .Subscribe(_ => validation.ValidateProperty(propertyExpression)));
 }
예제 #4
0
        public ReportParameterStepViewModel(ILog log, IDispatcherSchedulerProvider scheduler, IStandardDialog standardDialog,
                                            IReportParameterStepService service,
                                            IValidationAsync <ReportParameterStepViewModel, ReportParameterStepValidator> validation,
                                            BindableCollection <DateTime> datesCollection)
            : base(log, scheduler, standardDialog)
        {
            _service = service;

            _validation = validation;
            _validation.Initialise(this);
            _validation.ErrorsChanged
            .TakeUntil(ClosingStrategy.Closed)
            .ObserveOn(Scheduler.Dispatcher.RX)
            .Subscribe(x => ErrorsChanged.SafeInvoke(this, new DataErrorsChangedEventArgs(x)));

            Dates = datesCollection;
        }
예제 #5
0
        public ClientModel(IDispatcherSchedulerProvider scheduler, IValidationAsync <ClientModel, ClientValidator> validation)
            : base(scheduler, validation)
        {
            _firstName.ConnectINPCProperty(this, () => FirstName, scheduler).AddDisposable(Disposables);
            _firstName.AddValidation(Validation, scheduler, () => FirstName).AddDisposable(Disposables);

            _lastName.ConnectINPCProperty(this, () => LastName, scheduler).AddDisposable(Disposables);
            _lastName.AddValidation(Validation, scheduler, () => LastName).AddDisposable(Disposables);

            _fullName.ConnectINPCProperty(this, () => FullName, scheduler).AddDisposable(Disposables);

            _gender.ConnectINPCProperty(this, () => Gender, scheduler).AddDisposable(Disposables);
            _gender.AddValidation(Validation, scheduler, () => Gender).AddDisposable(Disposables);

            _addressLine1.ConnectINPCProperty(this, () => AddressLine1, scheduler).AddDisposable(Disposables);
            _addressLine1.AddValidation(Validation, scheduler, () => AddressLine1).AddDisposable(Disposables);

            _addressLine2.ConnectINPCProperty(this, () => AddressLine2, scheduler).AddDisposable(Disposables);
            _addressLine2.AddValidation(Validation, scheduler, () => AddressLine2).AddDisposable(Disposables);

            _postCode.ConnectINPCProperty(this, () => PostCode, scheduler).AddDisposable(Disposables);
            _postCode.AddValidation(Validation, scheduler, () => PostCode).AddDisposable(Disposables);

            _country.ConnectINPCProperty(this, () => Country, scheduler).AddDisposable(Disposables);
            _country.AddValidation(Validation, scheduler, () => Country).AddDisposable(Disposables);

            _dateOfBirth.ConnectINPCProperty(this, () => DateOfBirth, scheduler).AddDisposable(Disposables);
            _dateOfBirth.AddValidation(Validation, scheduler, () => DateOfBirth).AddDisposable(Disposables);

            ObservableEx.WhenAny(_firstName.ValueChanged, _lastName.ValueChanged)
            .Subscribe(x => FullName = string.Format("{0} {1}", x.Item1, x.Item2))
            .AddDisposable(Disposables);

            FirstName = string.Empty;
            LastName  = string.Empty;
        }