コード例 #1
0
        //
        // Parsing
        //

        public static Style Parse(string value)
        {
            Style style = new Style();

            if (!string.IsNullOrEmpty(value))
            {
                CSSStyleItemReader reader = new CSSStyleItemReader(value);
                var parser = new CSSStyleItemAllParser();

                while (reader.ReadNextAttributeName())
                {
                    parser.SetStyleValue(style, reader, null);
                }
            }

            return(style);
        }
コード例 #2
0
        //
        // implementation methods
        //

        #region protected virtual void Init(string text, IParserComponentFactory factory)

        /// <summary>
        /// Initializes this instance with the text and factory. Inheritors can override
        /// </summary>
        /// <param name="text"></param>
        /// <param name="factory"></param>
        protected virtual void Init(string text, IParserComponentFactory factory, IParserStyleFactory styles, HTMLParserSettings settings)
        {
            if (null == settings)
            {
                throw new ArgumentNullException(nameof(settings));
            }

            if (null == factory)
            {
                factory = new HTMLParserComponentFactory();
            }

            if (null == styles)
            {
                styles = new CSSStyleItemAllParser();
            }

            _text         = text;
            _instanceFact = factory;
            _settings     = settings;
            _styleFact    = styles;
            _shouldlog    = null != _settings.Context;
        }
コード例 #3
0
        //
        // implementation methods
        //

        #region protected virtual void Init(string text, IParserComponentFactory factory)

        /// <summary>
        /// Initializes this instance with the text and factory. Inheritors can override
        /// </summary>
        /// <param name="text"></param>
        /// <param name="factory"></param>
        protected virtual void Init(string text, IParserComponentFactory factory, IParserStyleFactory styles, HTMLParserSettings settings)
        {
            if (null == factory)
            {
                factory = new HTMLParserComponentFactory();
            }

            if (null == styles)
            {
                styles = new CSSStyleItemAllParser();
            }

            if (null == settings)
            {
                settings = new HTMLParserSettings();
            }

            _text         = text;
            _instanceFact = factory;
            _settings     = settings;
            _styleFact    = styles;

            _shouldlog = null != _settings.TraceLog && _settings.TraceLog.ShouldLog(_settings.LogLevel);
        }