Example #1
0
 private void AddPr_Click(object sender, RoutedEventArgs e)
 {
     if (string.IsNullOrWhiteSpace(FirstRule.Text) || string.IsNullOrWhiteSpace(SecondRule.Text))
     {
         MessageBox.Show("Недопустиммый ввод, проверьте правильнось ввода правил"); // если поля пустые
     }
     else
     {
         ListRules.Items.Add(FirstRule.Text + "->" + SecondRule.Text);
         FirstRule.Clear();
         SecondRule.Clear();
     }
 }
Example #2
0
        /// <inheritdoc />
        public IEnumerable <Message> Validate(IPropertyContainer propertyContainer)
        {
            Message[] messages1 = FirstRule.Validate(propertyContainer).ToArray();
            Message[] messages2 = LastRule.Validate(propertyContainer).ToArray();

            // Rule1 true; Rule2 true => true
            // Rule1 true; Rule2 false => true
            // Rule1 false; Rule2 true => true
            // Rule1 false; Rule2 false => false
            if (messages1.Length > 0 && messages2.Length > 0)
            {
                // messages1.Length > 0 && messages2.Length > 0 => OR rule failed.
                string message1 = messages1.Select(message => message.FormattedMessage).FormatAsTuple(startSymbol: "[", endSymbol: "]");
                string message2 = messages2.Select(message => message.FormattedMessage).FormatAsTuple(startSymbol: "[", endSymbol: "]");

                yield return(new Message($"{message1} or {message2}", severity: MessageSeverity.Error));
            }
        }
Example #3
0
        /// <inheritdoc />
        public IEnumerable <Message> Validate(IPropertyContainer propertyContainer)
        {
            foreach (var message in FirstRule.Validate(propertyContainer))
            {
                yield return(message);

                if (BreakOnFirstError)
                {
                    yield break;
                }
            }

            foreach (var message in LastRule.Validate(propertyContainer))
            {
                yield return(message);

                if (BreakOnFirstError)
                {
                    yield break;
                }
            }
        }