Beispiel #1
0
        public void TestMethod1()
        {
            IDictionary <string, object> src = new Dictionary <string, object>();
            var dest = new List <ExpandoObject>();

            src.Add(new KeyValuePair <string, object>("objectOne", "valueOne"));
            src.Add(new KeyValuePair <string, object>("objectTwo", "valueTwo"));
            src.Add(new KeyValuePair <string, object>("objectThree", "valueThree"));
            src.Add(new KeyValuePair <string, object>("objectFour", "valueFour"));

            var ruleList = new RuleList();
            var ruleOne  = new IncludeRule("!=", "string", "valueZero", true);
            var ruleSet  = new RuleSet();
            var iRules   = new List <IRule> {
                ruleOne
            };

            ruleList.RuleSets.Add(ruleSet);
            var ruleTwo   = new IncludeRule("==", "string", "valueOne", true);
            var ruleThree = new IncludeRule("==", "string", "valueTwo", true);
            var ruleFour  = new IncludeRule("==", "string", "valueThree", true);
            var ruleFive  = new ExcludeRule("==", "string", "valueThree", true);
            var ruleSix   = new ErrorCheckRule("!=", "string", "valueZero", true);


            //ruleList.RuleSets.Add();
            ruleList.Execute(src, ref dest);
        }
Beispiel #2
0
        private void PopulateListView(ExcludeRule rule)
        {
            var lvi = new ListViewItem();

            this.PopulateListView(lvi, rule);

            this.listView2.Items.Add(lvi);
        }
Beispiel #3
0
        private void PopulateListView(ListViewItem lvi, ExcludeRule rule)
        {
            lvi.Tag = rule;

            int i = 0;

            this.PopulateListViewItem(lvi, i++, rule.FileName);
        }
Beispiel #4
0
        /// <summary>
        /// 自定义一个排除规则对数据集进行排除
        /// </summary>
        /// <param name="excludeRule">自定义的排除规则</param>
        /// <returns>返回排除后的剩余的数据集</returns>
        public List <string> ExcludeNoMatching(ExcludeRule excludeRule)
        {
            List <string> restList = new List <string>();

            foreach (string str in _srcList)
            {
                if (excludeRule(str))
                {
                    restList.Add(str);
                }
            }
            return(restList);
        }
Beispiel #5
0
        public void SerializeRules()
        {
            var rule1 = new IncludeRule
            {
                ComparisonOperator = "==",
                ComparisonType     = "int",
                CompareRuleObject  = new KeyValuePair <string, object>("ShpId", "13"),
                ExpectedResult     = false
            };
            var rule2 = new IncludeRule
            {
                ComparisonOperator = "==",
                ComparisonType     = "int",
                CompareRuleObject  = new KeyValuePair <string, object>("ShpId", "14"),
                ExpectedResult     = false
            };
            var rule3 = new ExcludeRule
            {
                ComparisonOperator = "!=",
                ComparisonType     = "int",
                CompareRuleObject  = new KeyValuePair <string, object>("ShpId", "13"),
                ExpectedResult     = false
            };
            var rule4 = new ErrorCheckRule
            {
                ComparisonOperator = ">",
                ComparisonType     = "int",
                CompareRuleObject  = new KeyValuePair <string, object>("ShpId", "19"),
                ExpectedResult     = false
            };
            var ruleSet = new RuleSet();

            ruleSet.RuleSets.Add(rule1);
            ruleSet.RuleSets.Add(rule2);

            var ruleSet2 = new RuleSet();

            ruleSet2.RuleSets.Add(rule3);

            var ruleSet3 = new RuleSet();

            ruleSet3.RuleSets.Add(rule4);

            var ruleSets = new List <RuleSet> {
                ruleSet, ruleSet2, ruleSet3
            };

            var json = JsonConvert.SerializeObject(ruleSets);
        }
Beispiel #6
0
        /// <summary>
        /// When the user presses the 'OK' button.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">A empty <see cref="EventArgs"/>.</param>
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(this.tbFileName.Text))
            {
                MessageBox.Show(this, "The path must not be empty", this.Text);
                return;
            }

            if (this.includeRule == null)
            {
                this.includeRule = new ExcludeRule();
            }

            this.includeRule.FileName = this.tbFileName.Text;

            this.Close(DialogResult.OK);
        }
Beispiel #7
0
        private void Add(ExcludeRule rule)
        {
            this.collection.Add(rule);

            this.PopulateListView(rule);
        }
Beispiel #8
0
        /// <summary>
        /// When the user presses the 'OK' button.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">A empty <see cref="EventArgs"/>.</param>
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(this.tbFileName.Text))
            {
                MessageBox.Show(this, "The path must not be empty", this.Text);
                return;
            }

            if (this.includeRule == null)
            {
                this.includeRule = new ExcludeRule();
            }

            this.includeRule.FileName = this.tbFileName.Text;

            this.Close(DialogResult.OK);
        }
Beispiel #9
0
        private void Add(ExcludeRule rule)
        {
            this.collection.Add(rule);

            this.PopulateListView(rule);
        }
Beispiel #10
0
        private void PopulateListView(ListViewItem lvi, ExcludeRule rule)
        {
            lvi.Tag = rule;

            int i = 0;
            this.PopulateListViewItem(lvi, i++, rule.FileName);
        }
Beispiel #11
0
        private void PopulateListView(ExcludeRule rule)
        {
            var lvi = new ListViewItem();

            this.PopulateListView(lvi, rule);

            this.listView2.Items.Add(lvi);
        }