public RuleViewModel(RuleElement rule) { if (rule == null) { throw new ArgumentNullException("rule"); } ruleElement = rule; }
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); }
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); }
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; }
private static void RunUrl(Url url, RuleElement rule) { RunUrl(url, rule.Application, rule.Arguments); }
public void Remove(RuleElement rule) { if (BaseIndexOf(rule) >= 0) BaseRemove(rule.Name); }
public int IndexOf(RuleElement rule) { return BaseIndexOf(rule); }
public void Add(RuleElement rule) { BaseAdd(rule); }