• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# CsQuery.CQ类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中CsQuery.CQ的典型用法代码示例。如果您正苦于以下问题:C# CQ类的具体用法?C# CQ怎么用?C# CQ使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



CQ类属于CsQuery命名空间,在下文中一共展示了CQ类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: BuildBundleData

        public void BuildBundleData(ContentFragmentPageControl contentFragmentPage, CQ parsedContent)
        {
            if (Configuration.OptomizeGlobalCss)
            {
                //Get the themes CSS files
                CQ elements = parsedContent.Select(BuildSelector);

                foreach (IDomObject element in elements)
                {
                    string mediaType = element.GetAttribute("media") ?? "screen";

                    if (mediaType.IndexOf("screen", StringComparison.OrdinalIgnoreCase) > -1)
                    {
                        string src = element.GetAttribute("href");

                        if (!string.IsNullOrEmpty(src) && mediaType.IndexOf("dynamic-style.aspx", StringComparison.OrdinalIgnoreCase) < 0 && src.EndsWith(".css"))
                        {
                            IBundledFile file = _bundledFileFactory.GetBundleFile("css", src, contentFragmentPage, "");

                            if (file != null)
                            {
                                HandleLayoutCssPath(file);
                                
                                Include(file);
                            }
                        }
                    }
                }


            }
        }
开发者ID:4-Roads,项目名称:FourRoads.TelligentCommunity,代码行数:32,代码来源:StandardStyleBundle.cs


示例2: RunPattern

        private static void RunPattern(IYateDataContext dataContext, object model, CQ domObjects, IPattern pattern)
        {
            //try/finally leaves the data context in the same state as when we started with it hopefully.
            try
            {
                dataContext.PushValue(model);

                foreach (var domObject in domObjects)
                {
                    var htmlFragment = CQ.CreateFragment(pattern.HtmlFragment);

                    foreach (var atRule in pattern.AtRules)
                    {
                        atRule.Render(htmlFragment, dataContext);
                    }

                    foreach (var ruleSet in pattern.RuleSets)
                    {
                        ruleSet.Render(htmlFragment, dataContext);
                    }

                    //append those mama jammas
                    foreach(var frag in htmlFragment)
                    {
                        domObject.AppendChild(frag);
                    }
                }
            }
            finally
            {
                dataContext.PopValue();
            }
        }
开发者ID:jakeranderson,项目名称:Yate,代码行数:33,代码来源:ApplyPatternProperty.cs


示例3: Document

        public Document(FetchResult result)
        {
            _result = result;
            _document = CQ.CreateDocument(result.Content);

            _baseUri = new Lazy<Uri>(GetBaseUri);
        }
开发者ID:repne,项目名称:happyface,代码行数:7,代码来源:Document.cs


示例4: PreMailer

		/// <summary>
		/// Constructor for the PreMailer class
		/// </summary>
		/// <param name="html">The HTML input.</param>
		public PreMailer(string html)
		{
			_document = CQ.CreateDocument(html);
			_warnings = new List<string>();
			_cssParser = new CssParser();
			_cssSelectorParser = new CssSelectorParser();
		}
开发者ID:yonglehou,项目名称:PreMailer.Net,代码行数:11,代码来源:PreMailer.cs


示例5: Render

 public void Render(CQ html, string selector)
 {
     foreach (var property in Properties)
     {
         property.Render(html, selector);
     }
 }
开发者ID:jakeranderson,项目名称:Yate,代码行数:7,代码来源:Declaration.cs


示例6: Render

 public void Render(CQ dom)
 {
     foreach (var selector in _renderingParameters.Selectors)
     {
         ////todo: figure out prepend and such
         //if (renderingParameters.Expressions.Count() > 1)
         //{
         //    var method = renderingParameters.Expressions[1].ToLower();
         //    if (method == "append")
         //    {
         //        dom.Select(selector).Text(dom.Select(selector).Text() + renderingParameters.Expressions.FirstOrDefault());
         //    }
         //    else if (method == "prepend")
         //    {
         //        dom.Select(selector).Text(renderingParameters.Expressions.FirstOrDefault() + dom.Select(selector).Text());
         //    }
         //    else
         //    {
         //        dom.Select(selector).Text(renderingParameters.Expressions.FirstOrDefault());
         //    }
         //}
         //else
         //{
         dom.Select(selector).Text(_renderingParameters.Expressions.FirstOrDefault());
         //}
     }
 }
开发者ID:jakeranderson,项目名称:Yate,代码行数:27,代码来源:TextRenderingRule.cs


示例7: GetDefensiveTDs

        public static void GetDefensiveTDs(NPGGFFLDataContext context, Games game)
        {
            var foxSeasonType = (game.SeasonWeeks.SeasonTypeId == 1 ? 3 : (game.SeasonWeeks.SeasonTypeId == 2 ? 1 : 2));    //preseason = 3, reg season = 1, postseason = 2
            var foxScheduleUrl = string.Format("{0}?season={1}&seasonType={2}&week={3}", new string[] { SCHEDULE_URL, game.SeasonWeeks.SeasonYear.ToString(), foxSeasonType.ToString(), game.SeasonWeeks.WeekNum.ToString() });
            var foxLeagueUrl = string.Format("{0}?season={1}", new string[] { LEAGUE_URL, game.SeasonWeeks.SeasonYear.ToString() });

            var leagueJson = JObject.Parse(HelperMethods.GetJsonFromUrl(foxLeagueUrl));
            var scheduleJson = JArray.Parse(HelperMethods.GetJsonFromUrl(foxScheduleUrl));

            var awayTeam = GetFoxTeam(leagueJson, game.AwayTeam.FoxAbbreviation.ToUpper());
            var homeTeam = GetFoxTeam(leagueJson, game.HomeTeam.FoxAbbreviation.ToUpper());
            var gameUrl = string.Format("{0}{1}&type=3", HOST, GetFoxBoxscoreUrl(scheduleJson, awayTeam, homeTeam));

            var html = HelperMethods.LoadHtmlFromUrl(gameUrl);
            var dom = new CQ(html, HtmlParsingMode.Document);

            var dTDs = dom["div[class*='wisfb_bsTeamStats']"].Find("tr[class*='wisfb_bstsTotal wisfb_bstsGroupTop']:contains('DEF TDs')");
            if (dTDs.Length > 0)
            {
                var awayDefensiveTDs = Convert.ToInt32(dTDs.Find("td[class*='wisfb_bstsStat']")[0].Cq().Html());
                var homeDefensiveTDs = Convert.ToInt32(dTDs.Find("td[class*='wisfb_bstsStat']")[1].Cq().Html());

                context.PlayerStats.Where(ps => ps.GameId == game.GameId && ps.PlayerId == game.AwayTeamId).First().DefensiveTDs = awayDefensiveTDs;
                context.PlayerStats.Where(ps => ps.GameId == game.GameId && ps.PlayerId == game.HomeTeamId).First().DefensiveTDs = homeDefensiveTDs;
                context.SubmitChanges();
            }
        }
开发者ID:mpnieland,项目名称:NPGGFFL,代码行数:27,代码来源:FoxSportsScraper.cs


示例8: OnResultExecuted

        public override void OnResultExecuted(ResultExecutedContext filterContext)
        {
            if (sb == null)
            {
                base.OnResultExecuted(filterContext);
                return;
            }
            if (filterContext.Exception != null)
            {
                filterContext.RequestContext.HttpContext.Response.Output = output;
                base.OnResultExecuted(filterContext);
                return;
            }
            if (filterContext.HttpContext.Items.DocTransforms().Any())
            {
                string response = sb.ToString();
                //response processing

                var doc = new CsQuery.CQ(response);
                try
                {
                    foreach (var transform in filterContext.HttpContext.Items.DocTransforms())
                    {
                        transform(doc);
                    }
                    output.Write(doc.Render());
                }
                catch (Exception ex)
                {
                    output.Write(ex.ToString());
                    throw;
                }
            }
            base.OnResultExecuted(filterContext);
        }
开发者ID:genoher,项目名称:Noodles,代码行数:35,代码来源:ModifyDocumentAttribute.cs


示例9: Not

        /// <summary>
        /// Selects all elements except those passed as a parameter.
        /// </summary>
        ///
        /// <param name="elements">
        /// The elements to be excluded.
        /// </param>
        ///
        /// <returns>
        /// A new CQ object.
        /// </returns>
        ///
        /// <url>
        /// http://api.jquery.com/not/
        /// </url>

        public CQ Not(IEnumerable<IDomObject> elements)
        {
            CQ csq = new CQ(SelectionSet);
            csq.SelectionSet.ExceptWith(elements);
            csq.Selector = Selector;
            return csq;
        }
开发者ID:sahilpopli,项目名称:CsQuery,代码行数:23,代码来源:Not.cs


示例10: PreMailer

	    /// <summary>
	    /// Constructor for the PreMailer class
	    /// </summary>
	    /// <param name="html">The HTML input.</param>
        /// <param name="parsingMode">(optional) the mode.</param>
	    public PreMailer(string html,HtmlParsingMode parsingMode)
		{
            _document = CQ.Create(html, parsingMode);
			_warnings = new List<string>();
			_cssParser = new CssParser();
			_cssSelectorParser = new CssSelectorParser();
		}
开发者ID:granstel,项目名称:PreMailer.Net,代码行数:12,代码来源:PreMailer.cs


示例11: ToTomboyXml

        public static string ToTomboyXml(this string html_body)
        {
            var body = html_body.Replace ("<br>", "\n");
            CQ html = body;

            html["b"].ReplaceOuterWithTag("<bold/>");
            html["i"].ReplaceOuterWithTag ("<i/>");
            html["ul"].ReplaceOuterWithTag ("<list/>");
            html["li"].ReplaceOuterWithTag ("<list-item />");
            html["h1"].ReplaceOuterWithTag ("<size:huge/>");
            html["h2"].ReplaceOuterWithTag ("<size:large/>");
            html["small"].ReplaceOuterWithTag ("<size:small/>");
            html["strike"].ReplaceOuterWithTag ("<strikethrough/>");
            html["pre"].ReplaceOuterWithTag ("<monospace/>");
            html["a[class='internal']"].ReplaceOuterWithTag ("<link:internal/>");
            html["a[class='url']"].ReplaceOuterWithTag ("<link:url/>");

            html["a"].ReplaceOuterWithTag ("<link:url/>");

            html["span[class='highlight']"].ReplaceOuterWithTag ("<highlight/>");

            // hack replace <div> which get inserted by the wysihtml5
            html["div"].Each (domobj => {
                CQ e = new CQ (domobj);
                var all = new CQ(e.Html());
                e.ReplaceWith(all);
            });

            var render = html.Render ();
            // maybe bug int tomboy - </list-items> need a single \n in from of them
            render = Regex.Replace (render, @"(?!\n)</list-item>", "\n</list-item>", RegexOptions.ExplicitCapture);
            return render;
        }
开发者ID:Dynalon,项目名称:Rainy,代码行数:33,代码来源:NoteHtmlConversion.cs


示例12: UnquotedAttributeHandling

        public void UnquotedAttributeHandling()
        {

            CQ doc = new CQ("<div custattribute=10/23/2012 id=\"tableSample\"><span>sample text</span></div>");
            IDomElement obj = doc["#tableSample"].FirstElement();

            Assert.AreEqual("10/23/2012", obj["custattribute"]);
        }
开发者ID:TheX,项目名称:CsQuery,代码行数:8,代码来源:EdgeCases.cs


示例13: ReadLargeDoc

        public static void ReadLargeDoc(TestContext context)
        {
            // CsQuery (version 1.3.0 and above) uses this code.

            Dom = CQ.Create(
                CsQuery.Utility.Support.GetFile("HtmlParserSharp.Tests\\Resources\\html standard.htm")
            );
        }
开发者ID:antrampa,项目名称:HtmlParserSharp,代码行数:8,代码来源:Basic.cs


示例14: ParseEventDate

        static DateTimeOffset ParseEventDate(CQ dom, IDomObject @event)
        {
            var date = dom.Select("td.date", @event).Text().Trim();

            DateTimeOffset eventDate;
            DateTimeOffset.TryParse(date, out eventDate);

            return eventDate;
        }
开发者ID:oreshkor,项目名称:luckybird,代码行数:9,代码来源:SoccerPageParser.cs


示例15: TestObtainAccessTokenWithoutAuthenticating

 public void TestObtainAccessTokenWithoutAuthenticating()
 {
     var collection = new CollectionState(new Uri(SANDBOX_URI));
     var response = new WebClient().DownloadString("http://checkip.dyndns.com/");
     var ip = new CQ(response).Select("body").Text().Split(new string[] { ": " }, StringSplitOptions.RemoveEmptyEntries)[1].Trim();
     var state = collection.UnauthenticatedAccess(ip, "WCQY-7J1Q-GKVV-7DNM-SQ5M-9Q5H-JX3H-CMJK");
     Assert.AreEqual(HttpStatusCode.OK, state.Response.StatusCode);
     Assert.IsNotNullOrEmpty(state.CurrentAccessToken);
 }
开发者ID:Herbert42,项目名称:gedcomx-csharp,代码行数:9,代码来源:AuthenticationTests.cs


示例16: GetGameDate

 public static DateTime GetGameDate(int gameId)
 {
     var url = string.Format("{0}{1}", BOXSCORE_URL, string.Format("?gameId={0}", gameId.ToString()));
     var html = HelperMethods.LoadHtmlFromUrl(url);
     CQ dom = new CQ(html, HtmlParsingMode.Document);
     var gameTime = dom["div[class*='game-status']"].Find("span[data-date]").First().Attr("data-date");
     var gameDtm = DateTime.Parse(gameTime);
     return gameDtm;
 }
开发者ID:mpnieland,项目名称:NPGGFFL,代码行数:9,代码来源:ESPNScraper.cs


示例17: Result

        internal object Result()
        {
            var s = new CQ(compareSource);
            var w = new CQ(compareWith);

            

            throw new NotImplementedException();
        }
开发者ID:joeriks,项目名称:DryHtml,代码行数:9,代码来源:HtmlComparer.cs


示例18: ParseCommandsNames

 static string[] ParseCommandsNames(CQ dom, IDomObject @event)
 {
     var commands =
         dom.Select(
             "td.today-name > span.command > div.today-member-name, td.name > span.command div.member-name",
             @event).Map(node => node.Cq().Text().Trim().Replace(Nbsp, ' ')).ToArray();
     Debug.Assert(commands.Count() == 2, "Teams names have not been recognized: " + @event.InnerHTML);
     return commands;
 }
开发者ID:oreshkor,项目名称:luckybird,代码行数:9,代码来源:SoccerPageParser.cs


示例19: InitializeDomFromTemplate

 private void InitializeDomFromTemplate()
 {
     using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("ApiExplorer.Core.Template.html"))
     {
         using (StreamReader reader = new StreamReader(stream))
         {
             Dom = CQ.Create(reader.ReadToEnd());
         }
     }
 }
开发者ID:satish860,项目名称:ApiDocumentation,代码行数:10,代码来源:HtmlOutputGenerator.cs


示例20: Format

        public string Format(CQ selection)
        {
            stringInfo = CharacterData.CreateStringInfo();

            StringBuilder sb = new StringBuilder();
            foreach (IDomObject obj in selection) {
                AddContents(sb,obj);
            }
            return sb.ToString();
        }
开发者ID:fluffysquirrels,项目名称:ProgNet2012-Completed,代码行数:10,代码来源:FormatPlainText.cs



注:本文中的CsQuery.CQ类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Data.SafeDataReader类代码示例发布时间:2022-05-24
下一篇:
C# CsJni.JniEnvironment类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap