Esempio n. 1
0
        // parsing

        #region public static PDFStyleMatcher Parse(string selector)

        public static PDFStyleMatcher Parse(string selector)
        {
            if (string.IsNullOrEmpty(selector))
            {
                return(null);
            }

            selector = selector.Trim();

            if (string.IsNullOrEmpty(selector))
            {
                return(null);
            }

            if (string.Equals("*", selector))
            {
                return(new PDFStyleCatchAllMatcher());
            }

            var each = selector.Split(", ", StringSplitOptions.RemoveEmptyEntries);

            if (each.Length > 1)
            {
                PDFStyleMatcher root = null;

                foreach (var one in each)
                {
                    var all = one.Split(" ", StringSplitOptions.RemoveEmptyEntries);

                    StylePlacement placement = StylePlacement.Any;
                    var            parsed    = ParseSelectorList(all, all.Length - 1, placement);

                    if (null == root)
                    {
                        root = new PDFStyleMatcher(parsed);
                    }
                    else
                    {
                        root = new PDFStyleMultipleMatcher(parsed, root);
                    }
                }
                return(root);
            }
            else
            {
                var all = String.IsNullOrEmpty(selector) ? new string[] { } : selector.Split(" ", StringSplitOptions.RemoveEmptyEntries);

                StylePlacement placement = StylePlacement.Any;
                var            one       = ParseSelectorList(all, all.Length - 1, placement);


                return(new PDFStyleMatcher(one));
            }
        }
        //
        // ..ctor
        //

        #region public PDFStyleMultipleMatcher(PDFStyleMatch current, PDFStyleMatcher next) : base(current)

        public PDFStyleMultipleMatcher(PDFStyleSelector current, PDFStyleMatcher next) : base(current)
        {
            this.Next = next;
        }