public SmartViewBlockRule(IEnumerable <SmartViewRule> rules, SmartViewMatchType match) { if (rules == null) { throw new ArgumentNullException("rules"); } this.match = match; this.rules = new List <SmartViewRule>(rules); }
public static string GetMatchTypeDisplay(SmartViewMatchType type) { if (type == SmartViewMatchType.All) { return(StringResources.SmartView_And); } else { return(StringResources.SmartView_Or); } }
public SmartViewHandler(SmartViewMatchType match, IEnumerable <SmartViewBlockRule> blocks) { if (blocks == null) { throw new ArgumentNullException("blocks"); } this.Match = match; this.Blocks = new List <SmartViewBlockRule>(blocks); this.ShowCompletedTasks = this.Blocks.Any(b => b.Rules.Any(r => r.Field == SmartViewField.Completed)); }
protected async void LoadStringAsync(string content) { Exception exception = null; try { var handler = SmartViewHandler.FromString(content); foreach (var block in handler.Blocks) { var blockViewModel = new SmartViewBlockViewModel(this); foreach (var rule in block.Rules) { var ruleViewModel = new SmartViewRuleViewModel(blockViewModel) { SelectedField = rule.Field, SelectedFilter = rule.Filter, Value = this.CreateValueViewModel(rule.Filter, rule.Field, rule.Value) }; blockViewModel.Rules.Add(ruleViewModel); } if (block.Match == SmartViewMatchType.All) { blockViewModel.MatchAnd = true; } else { blockViewModel.MatchOr = true; } this.blocks.Add(blockViewModel); } this.matchType = handler.Match; } catch (Exception ex) { exception = ex; } if (exception != null) { await this.messageBoxService.ShowAsync(StringResources.Message_Warning, string.Format(StringResources.SmartView_MessageCannotLoadFormat, exception)); } }
public static T AssertRule<T>(this SmartViewHandler handler, int block, int rule, int ruleCount, SmartViewMatchType type, SmartViewField field, SmartViewFilter filter, Func<T, bool> checkRule) where T : SmartViewRule { SmartViewBlockRule smartViewBlockRule = handler.Blocks[block]; Assert.AreEqual(ruleCount, smartViewBlockRule.Rules.Count); Assert.AreEqual(type, smartViewBlockRule.Match); SmartViewRule smartViewRule = smartViewBlockRule.Rules[rule]; Assert.AreEqual(field, smartViewRule.Field); Assert.AreEqual(filter, smartViewRule.Filter); SmartViewRule item = smartViewRule; Assert.IsTrue(item is T); Assert.IsTrue(checkRule((T) item)); return (T) item; }
public static void AssertContent(this SmartViewHandler handler, int blockCount,SmartViewMatchType type) { Assert.AreEqual(blockCount, handler.Blocks.Count); Assert.AreEqual(type, handler.Match); }