Example #1
0
        /// <summary>
        /// extract base from content
        /// </summary>
        /// <param name="content">content need to be extract</param>
        /// <param name="extractBase">extract base</param>
        /// <returns>extract result collection</returns>
        public static ExtractResultCollection ExtractSelector(string content, ExtractBase extractBase)
        {
            var pr = ProcessorManager.Process(content, extractBase.Selectors);

            var results = new ExtractResultCollection();

            foreach (var m in pr.Matches)
            {
                ExtractResult result;

                try
                {
                    result = new ExtractResult
                    {
                        Name    = "tile",
                        Content = Convert.ChangeType(m, extractBase.DataType)
                    };
                }
                catch
                {
                    result = new ExtractResult
                    {
                        Name    = "tile",
                        Content = m
                    };
                }

                results.Add(result);
            }

            return(results);
        }
Example #2
0
        /// <summary>
        /// extract block collection from content
        /// </summary>
        /// <param name="content">content need to be extract</param>
        /// <param name="collection">block collection</param>
        /// <returns>extract result collection</returns>
        public static ExtractResultCollection Extract(string content, ExtractBlockCollection collection)
        {
            var results = new ExtractResultCollection();

            foreach (var block in collection)
            {
                var r = Extract(content, block);
                results.Add(r);
            }

            return(results);
        }
Example #3
0
        /// <summary>
        /// extract tile from content
        /// </summary>
        /// <param name="content">content need to be extract</param>
        /// <param name="tile">extract tile</param>
        /// <returns>extract result collection</returns>
        public static ExtractResultCollection ExtractTile(string content, ExtractTile tile)
        {
            var pr = ProcessorManager.Process(content, tile.Selectors);

            var results = new ExtractResultCollection();

            foreach (var m in pr.Matches)
            {
                var result = new ExtractResult
                {
                    Name    = "tile",
                    Content = m
                };

                if (tile.Metas.Count > 0)
                {
                    result.Metas = ExtractMeta(m, tile.Metas);
                }

                results.Add(result);
            }

            return(results);
        }