コード例 #1
0
        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());
        }
コード例 #2
0
ファイル: StyleSheet.cs プロジェクト: hongliyu2002/XamlCSS
        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));
        }
コード例 #3
0
ファイル: StyleSheet.cs プロジェクト: banshanju/XamlCSS
        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());
        }