Beispiel #1
0
        public IEnumerable <CheckResult> Check(Config.RuleItem rule)
        {
            if (rule == null)
            {
                throw new ArgumentNullException(nameof(rule));
            }
            else if (rule.Check == null)
            {
                throw new ArgumentNullException($"{nameof(rule)}.{nameof(Config.RuleItem.Check)}");
            }
            else if (rule.Check.Any(c => c == null))
            {
                throw new ArgumentException("A check must not be null", $"{nameof(rule)}.{nameof(Config.RuleItem.Check)}");
            }
            else if (rule.Check.Any(c => c.Item == null))
            {
                throw new ArgumentException("A check item must not be null", $"{nameof(rule)}.{nameof(Config.RuleItem.Check)}.{nameof(Config.CheckItem.Item)}");
            }

            var filtered = rule.Filter != null
                ? rule.Filter.Filter(_profiles)
                : _profiles;

            foreach (var check in rule.Check)
            {
                var failedProfiles = check.Item.Check(filtered);

                yield return(new CheckResult(check, failedProfiles));
            }
        }
        private void AddRuleListRow(Config.RuleItem rule)
        {
            var row = new ListViewItem();

            DrawRuleListItem(row, rule);

            RuleListView.Items.Add(row);
        }
        private void OnAddRuleButtonClick(object sender, EventArgs e)
        {
            var newItem = new Config.RuleItem();

            using (var form = new RuleForm(newItem))
            {
                if (form.ShowDialog() == DialogResult.OK)
                {
                    var list = (EditValue.Rule ?? Enumerable.Empty <Config.RuleItem>()).ToList();

                    list.Add(newItem);

                    EditValue.Rule = list.ToArray();

                    AddRuleListRow(newItem);

                    HasChanged = true;
                }
            }
        }
        private void DrawRuleListItem(ListViewItem row, Config.RuleItem item)
        {
            row.Tag = item;

            row.SubItems[0].Text = item.Name;
        }