예제 #1
0
        public RuleViewModel(RuleElement rule)
        {
            if (rule == null)
            {
                throw new ArgumentNullException("rule");
            }

            ruleElement = rule;
        }
예제 #2
0
        public void ToUrlStringAllFilledTest()
        {
            var expected = "http://insite";

            var target = new RuleElement();
            target.Protocol = "http";
            target.Pattern = "^insite(/.*)?$";

            var actual = target.ToUrlString();
            Assert.AreEqual(expected, actual);
        }
예제 #3
0
        public void RuleElementCtorUrlTest()
        {
            var expectedProtocol = "http";
            var expectedPattern = "^test.ru(/.*)?$";
            var initValue = "http://test.ru";

            var target = new RuleElement(initValue);

            Assert.AreEqual(expectedPattern, target.Pattern);
            Assert.AreEqual(expectedProtocol, target.Protocol);
        }
예제 #4
0
        private static bool CheckRule(RuleElement rule, Url url)
        {
            if (!string.IsNullOrEmpty(rule.Protocol) &&
                !rule.Protocol.Equals(url.Protocol, StringComparison.InvariantCultureIgnoreCase))
            {
                return false;
            }

            if (!string.IsNullOrEmpty(rule.ProcessName) &&
                !rule.ProcessName.Equals(url.ProcessName, StringComparison.InvariantCultureIgnoreCase))
            {
                return false;
            }

            if (!string.IsNullOrEmpty(rule.Pattern) &&
                !Regex.IsMatch(url.UrlWithoutProtocol, rule.Pattern))
            {
                return false;
            }

            return true;
        }
예제 #5
0
 private static void RunUrl(Url url, RuleElement rule)
 {
     RunUrl(url, rule.Application, rule.Arguments);
 }
예제 #6
0
 public void Remove(RuleElement rule)
 {
     if (BaseIndexOf(rule) >= 0)
         BaseRemove(rule.Name);
 }
예제 #7
0
 public int IndexOf(RuleElement rule)
 {
     return BaseIndexOf(rule);
 }
예제 #8
0
 public void Add(RuleElement rule)
 {
     BaseAdd(rule);
 }