protected List <StyleRule> GetCombinedStyleRules() { if (BaseStyleSheets.Count == 0 && InheritedStyleSheets.Count == 0) { return(LocalRules); } if (InheritedStyleSheets.Contains(this)) { throw new InvalidOperationException("A stylesheet cannot be attached to multiple elements at the same time!"); } return(InheritedStyleSheets .SelectMany(x => x.Rules.ToList()) .Concat(BaseStyleSheets.SelectMany(x => x.Rules.ToList())) .Concat(LocalRules) .GroupBy(x => x.SelectorString) .Select(x => new StyleRule { Selectors = x.First().Selectors, DeclarationBlock = new StyleDeclarationBlock(GetMergedStyleDeclarations(x.ToList()), x.SelectMany(y => y.DeclarationBlock.Triggers).ToList()) }) .ToList()); }
protected IDictionary <string, string> GetCombinedVariables() { if (BaseStyleSheets.Count == 0 && InheritedStyleSheets.Count == 0) { return(Variables); } return(InheritedStyleSheets .SelectMany(x => x.Variables.ToList()) .Concat(BaseStyleSheets.SelectMany(x => x.Variables.ToList())) .Concat(Variables) .GroupBy(x => x.Key) .Select(x => x.Last()) .ToDictionary(x => x.Key, x => x.Value)); }
protected List <StyleRule> GetCombinedStyleRules() { if (BaseStyleSheets.Count == 0 && InheritedStyleSheets.Count == 0) { return(LocalRules); } return(InheritedStyleSheets .SelectMany(x => x.Rules.ToList()) .Concat(BaseStyleSheets.SelectMany(x => x.Rules.ToList())) .Concat(LocalRules) .GroupBy(x => x.SelectorString) .Select(x => new StyleRule { Selectors = x.First().Selectors, DeclarationBlock = new StyleDeclarationBlock(GetMergedStyleDeclarations(x.ToList()), x.SelectMany(y => y.DeclarationBlock.Triggers).ToList()) }) .ToList()); }