Esempio n. 1
0
        public BaseViewModel()
        {
            Validator = new ValidationHelper();

            NotifyDataErrorInfoAdapter = new NotifyDataErrorInfoAdapter(Validator);
            NotifyDataErrorInfoAdapter.ErrorsChanged += OnErrorsChanged;
        }
Esempio n. 2
0
        protected ValidatableViewModelBase()
        {
            Validator = new ValidationHelper();

            NotifyDataErrorInfoAdapter = new NotifyDataErrorInfoAdapter(Validator);
            NotifyDataErrorInfoAdapter.ErrorsChanged += OnErrorsChanged;
        }
Esempio n. 3
0
        private void SetupValidation()
        {
            var validationRules = new ValidationHelper();

            // Simple properties
            validationRules.AddRule(nameof(StringProperty),
                                    () =>
                                    RuleResult.Assert(!string.IsNullOrEmpty(StringProperty),
                                                      "StringProperty cannot be null or empty string"));

            validationRules.AddRule(nameof(IntProperty),
                                    () => RuleResult.Assert(IntProperty > 0, "IntProperty should be greater than zero."));

            // Dependant properties
            validationRules.AddRule(nameof(RangeStart),
                                    nameof(RangeEnd),
                                    () => RuleResult.Assert(RangeEnd > RangeStart, "RangeEnd must be grater than RangeStart"));

            // Long-running validation (simulates call to a web service or something)
            validationRules.AddRule(
                nameof(StringProperty2),
                () =>
            {
                SyncValidationRuleExecutedAsyncroniouslyDelegate?.Invoke();

                return(RuleResult.Assert(!string.IsNullOrEmpty(StringProperty2),
                                         "StringProperty2 cannot be null or empty string"));
            });

            Validation = validationRules;
            DataErrorInfoValidationAdapter = new NotifyDataErrorInfoAdapter(Validation);
        }
        public ValidateableBaseViewModel()// IUnityContainer container)
        {
            Validator = new ValidationHelper();

            NotifyDataErrorInfoAdapter = new NotifyDataErrorInfoAdapter(Validator);
            NotifyDataErrorInfoAdapter.ErrorsChanged += OnErrorsChanged;
        }
Esempio n. 5
0
        protected ViewModelBase(IUnitOfWorkFactory factory)
        {
            this.factory = factory;

            Validator = new ValidationHelper();
            NotifyDataErrorInfoAdapter = new NotifyDataErrorInfoAdapter(Validator);
            NotifyDataErrorInfoAdapter.ErrorsChanged += OnErrorChanged;
        }
 public IEnumerable GetErrors(string propertyName)
 {
     try
     {
         return(NotifyDataErrorInfoAdapter.GetErrors(propertyName));
     }
     catch (Exception ex)
     {
         return(null);
     }
 }
        public Student()
        {
            Validator = new ValidationHelper();

            this.PropertyChanged      += Student_PropertyChanged;
            NotifyDataErrorInfoAdapter = new NotifyDataErrorInfoAdapter(Validator);


            OnCreated();
            ConfigureRules();
        }
Esempio n. 8
0
        public ValidatableViewModelBase()
        {
            Validator = new ValidationHelper();

            #if SILVERLIGHT
            NotifyDataErrorInfoAdapter = new NotifyDataErrorInfoAdapter(Validator);
            #else
            DataErrorInfoAdapter = new DataErrorInfoAdapter(Validator);
            #endif

            OnCreated();
        }
Esempio n. 9
0
        //constructor for mainview
        public MainViewModel(IDialogCoordinator dialogCoordinator)
        {
            _canExecute        = true;
            _dialogCoordinator = dialogCoordinator;
            try
            {
                Channel_list  = mysql_data.get_channel_list();
                Mysql_Status  = mysql_data.live_ping();
                Sqlite_Status = mysql_data.localDB_ping();

                Validator = new ValidationHelper();
                NotifyDataErrorInfoAdapter = new NotifyDataErrorInfoAdapter(Validator);
            }
            catch
            {
            }
        }
        protected ValidatableViewModelBase()
        {
            NotifyDataErrorInfoAdapter = new NotifyDataErrorInfoAdapter(Validator);

            Observable.FromEventPattern <DataErrorsChangedEventArgs>(
                ev => NotifyDataErrorInfoAdapter.ErrorsChanged += ev,
                ev => NotifyDataErrorInfoAdapter.ErrorsChanged -= ev)
            .Select(e => e.EventArgs.PropertyName)
            .Subscribe(OnPropertyChanged);

            var obs = Observable.FromEventPattern <ValidationResultChangedEventArgs>(
                ev => Validator.ResultChanged += ev,
                ev => Validator.ResultChanged -= ev)
                      .Select(e => e.EventArgs.NewResult)
                      .CombineLatest(IsValid, ValidateCommand as ReactiveCommand, (a, b, c) => (a, b, c))
                      .Where((ab) => ab.b == false)
                      .Select(ab => ab.a);

            obs.Subscribe(a => IsValid.Value = a.IsValid);
            ValidationErrorsString           = obs.Select(a => a.ToString()).ToReadOnlyReactiveProperty();
        }
Esempio n. 11
0
        public MainViewModel(IDialogCoordinator dialogCoordinator)
        {
            Validator = new ValidationHelper();

            NotifyDataErrorInfoAdapter = new NotifyDataErrorInfoAdapter(Validator);
            Validator.AddRequiredRule(() => Asset_tag, "Asset Tag is required");
            Validator.AddRequiredRule(() => Selected_resou, "Please Select Resolution");
            Validator.AddRequiredRule(() => Selected_device, "Please Select a Device");
            NotifyDataErrorInfoAdapter.ErrorsChanged += OnErrorsChanged;

            _canExecute        = true;
            _dialogCoordinator = dialogCoordinator;
            Mysql_Status       = mysql_data.live_ping();
            Sqlite_Status      = mysql_data.localDB_ping();


            //Validator.AddRequiredRule(() => Users_SelectedValue, "User is required");
            //Validator.AddRequiredRule(() => Computer_type_value, "Computer Type is required");
            //Validator.AddRequiredRule(() => Selected_channel, "Channel is required");
            //Validator.AddRequiredRule(() => Selected_sku, "SKU is required");
        }
 public ValidatableViewModel()
 {
     Validator = new ValidationHelper();
     DataErrorInfoValidationAdapter = new NotifyDataErrorInfoAdapter(Validator);
 }
 public ValidatableViewModel()
 {
     Validator = new ValidationHelper();
     DataErrorInfoValidationAdapter = new NotifyDataErrorInfoAdapter(Validator);
 }
 public ValidatableObservableObject()
 {
     _validator = new ValidationHelper();
     _notifyDataErrorInfoAdapter = new NotifyDataErrorInfoAdapter(_validator);
     _notifyDataErrorInfoAdapter.ErrorsChanged += OnErrorsChanged;
 }
Esempio n. 15
0
 public IEnumerable GetErrors(string propertyName)
 {
     return(NotifyDataErrorInfoAdapter.GetErrors(propertyName));
 }
Esempio n. 16
0
        private void SetupValidation()
        {
            var validationRules = new ValidationHelper();

            // Simple properties
            validationRules.AddRule(() => StringProperty,
                                    () => { return RuleResult.Assert(!string.IsNullOrEmpty(StringProperty), "StringProperty cannot be null or empty string"); });

            validationRules.AddRule(() => IntProperty,
                                    () => { return RuleResult.Assert(IntProperty > 0, "IntProperty should be greater than zero."); });

            // Dependant properties
            validationRules.AddRule(() => RangeStart,
                                    () => RangeEnd,
                                    () =>
                                    {
                                        return RuleResult.Assert(RangeEnd > RangeStart, "RangeEnd must be grater than RangeStart");
                                    });

            // Long-running validation (simulates call to a web service or something)
            validationRules.AddRule(
                () => StringProperty2,
                () =>
                {
                    if (SyncValidationRuleExecutedAsyncroniouslyDelegate != null)
                    {
                        SyncValidationRuleExecutedAsyncroniouslyDelegate();
                    }

                    return RuleResult.Assert(!string.IsNullOrEmpty(StringProperty2), "StringProperty2 cannot be null or empty string");
                });

            Validation = validationRules;
            DataErrorInfoValidationAdapter = new NotifyDataErrorInfoAdapter(Validation);
        }
Esempio n. 17
0
 public ValidatingViewModel()
 {
     this.Validator = new ValidationHelper();
     this.notifyDataErrorInfoAdapter = new NotifyDataErrorInfoAdapter(this.Validator);
 }