예제 #1
0
        public override bool IsValid()
        {
            bool isValid = base.IsValid();

            OnValidation?.Invoke(isValid);

            return(isValid);
        }
예제 #2
0
 public TValidator RegisterValidator<TViewModel, TValidator>()
     where TValidator : AbstractValidator<TViewModel>
     where TViewModel : ViewModel
 {
     TValidator validator = Activator.CreateInstance<TValidator>();
     PropertyChanged += (o, ev) =>
     {
         var result = validator.Validate((TViewModel)this);
         ValidationResult = result;
         OnValidation?.Invoke(result);
     };
     return validator;
 }
예제 #3
0
        public void UpdateExpiresTime(string?time)
        {
            if (string.IsNullOrEmpty(time))
            {
                _expiresTime = null;
            }
            else
            {
                _expiresTime = DateTime.Parse(time).TimeOfDay;
            }

            ValidateExpiresDateTime();
            OnValidation.Invoke();
        }
예제 #4
0
        public void UpdateExpiresDate(string?date)
        {
            if (string.IsNullOrEmpty(date))
            {
                _expiresDate = null;
            }
            else
            {
                _expiresDate = DateTime.Parse(date);
            }

            ValidateExpiresDateTime();
            OnValidation.Invoke();
        }
예제 #5
0
 /// <summary>
 /// Raises the OnValidation event.
 /// </summary>
 /// <param name="sender">Object which raises the event.</param>
 /// <param name="eventArgs">Arguments for the event.</param>
 protected virtual void RaiseOnValidationEvent(object sender, IDataValidatorEventArgs eventArgs)
 {
     if (sender == null)
     {
         throw new ArgumentNullException("sender");
     }
     if (eventArgs == null)
     {
         throw new ArgumentNullException("eventArgs");
     }
     if (OnValidation != null)
     {
         OnValidation.Invoke(sender, eventArgs);
     }
 }
예제 #6
0
        public void SetExpirationAfterTimespan(TimeSpan timeSpan)
        {
            if (timeSpan != TimeSpan.Zero)
            {
                _expiresDate = DateTime.Now.Add(timeSpan).Date;
                _expiresTime = DateTime.Now.Add(timeSpan).TimeOfDay;
            }
            else
            {
                _expiresDate = null;
                _expiresTime = null;
            }

            ValidateExpiresDateTime();
            OnValidation.Invoke();
        }
예제 #7
0
        public void UpdateHostnameList(List <string> hostnames)
        {
            if (hostnames.Count == 0)
            {
                _newWhitelist.Hostnames = null;
                return;
            }

            _newWhitelist.Hostnames = new List <string>();
            foreach (string hostname in hostnames)
            {
                // if (hostname != "" && ValidateHostname(hostname).Item1 != Validation.ValidationResult.Invalid)
                _newWhitelist.Hostnames.Add(hostname);
            }

            OnValidation.Invoke();
        }
예제 #8
0
        public void UpdateIPList(List <string> ips)
        {
            if (ips.Count == 0)
            {
                _newWhitelist.IPs = null;
                return;
            }

            _newWhitelist.IPs = new List <IPAddress>();
            foreach (string ip in ips)
            {
                // if (ip != "" && ValidateIP(ip).Item1 == Validation.ValidationResult.Valid)
                _newWhitelist.IPs.Add(IPAddress.Parse(ip));
            }

            OnValidation.Invoke();
        }
예제 #9
0
        public void UpdateVendorList(List <string> vendors)
        {
            if (vendors.Count == 0)
            {
                _newWhitelist.Vendors = null;
                return;
            }

            _newWhitelist.Vendors = new List <string>();
            foreach (string vendor in vendors)
            {
                if (vendor != "")
                {
                    _newWhitelist.Vendors.Add(vendor);
                }
            }

            OnValidation.Invoke();
        }
예제 #10
0
        public void UpdateSubnetList(List <string> subnets)
        {
            if (subnets.Count == 0)
            {
                _newWhitelist.Subnets = null;
                return;
            }

            _newWhitelist.Subnets = new List <IPNetwork>();
            foreach (string subnet in subnets)
            {
                if (subnet != "")
                {
                    _newWhitelist.Subnets.Add(IPNetwork.Parse(subnet));
                }
            }

            OnValidation.Invoke();
        }
예제 #11
0
 public void OnPostValidate()
 {
     OnValidation?.Invoke();
 }
예제 #12
0
 public void Validate()
 {
     CacheResults();
     _refreshTrigger.Trigger();
     OnValidation?.Invoke();
 }
예제 #13
0
 private void NameTB_TextChanged(object sender, EventArgs e)
 {
     AfterTextChangedMethod?.Invoke();
     AfterTextChangedMethod = null;
 }