Esempio n. 1
0
    public int getMinimalCssRuleCount(string[] xthml)
    {
        string s = "";

        foreach (string sss in xthml)
        {
            s += sss;
        }
        char[]   c  = new char[] { '<', '>' };
        string[] ss = s.Split(c, StringSplitOptions.RemoveEmptyEntries);
        //foreach(string sss in ss) Console.WriteLine(sss);
        dic    = new Dictionary <string, int>();
        tagdic = new Dictionary <string, int>();
        int i;

        for (i = 0; i < color.Length; i++)
        {
            dic[color[i]] = i;
        }
        for (i = 0; i < tag.Length; i++)
        {
            tagdic[tag[i]] = i;
        }
        css first = new css(7, 7);
        css now   = first;

        for (i = 0; i < ss.Length; i++)
        {
            string next = ss[i];
            if (next[0] == '/')
            {
                now = now.mother;
            }
            else
            {
                int color, tag;
                //<b id='x' style='color:red'
                char[]   newset = new char[] { ' ', ':', '\'' };
                string[] s1     = ss[i].Split(newset, StringSplitOptions.RemoveEmptyEntries);
                tag   = tagdic[s1[0]];
                color = dic[s1[s1.Length - 1]];
                css child = new css(color, tag);
                now.add(child);
                now = child;
            }
        }
        return(first.getnum());
    }