예제 #1
0
        public XCssRules Optimize()
        {
            var d = new Dictionary <XCssDeclaration, List <string> >();

            foreach (var rule in Rules)
            {
                foreach (var declaration in rule.Declarations)
                {
                    if (!d.Keys.Any(_d => _d.ToString() == declaration.ToString()))
                    {
                        d[declaration] = new List <string>();
                    }
                    var l = d[d.Keys.First(_d => _d.ToString() == declaration.ToString())];
                    if (!l.Contains(rule.Selector))
                    {
                        l.Add(rule.Selector);
                    }
                }
            }

            var rules = new XCssRules();

            foreach (var declaration in d.Keys)
            {
                var l = d[declaration];

                rules.Add(string.Join(", ", l.ToArray()), declaration);
            }

            return(rules);
        }
예제 #2
0
        public XCssRules Optimize()
        {
            var d = new Dictionary<XCssDeclaration, List<string>>();
            foreach (var rule in Rules)
            {
                foreach (var declaration in rule.Declarations)
                {
                    if (!d.Keys.Any(_d => _d.ToString() == declaration.ToString()))
                    {
                        d[declaration] = new List<string>();
                    }
                    var l = d[d.Keys.First(_d => _d.ToString() == declaration.ToString())];
                    if (!l.Contains(rule.Selector))
                    {
                        l.Add(rule.Selector);
                    }
                }
            }

            var rules = new XCssRules();
            
            foreach (var declaration in d.Keys)
            {
                var l = d[declaration];

                rules.Add(string.Join(", ", l.ToArray()), declaration);
            }

            return rules;
        }