当前位置: 首页>>代码示例>>C#>>正文


C# ConcurrentQueue.OrderBy方法代码示例

本文整理汇总了C#中ConcurrentQueue.OrderBy方法的典型用法代码示例。如果您正苦于以下问题:C# ConcurrentQueue.OrderBy方法的具体用法?C# ConcurrentQueue.OrderBy怎么用?C# ConcurrentQueue.OrderBy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ConcurrentQueue的用法示例。


在下文中一共展示了ConcurrentQueue.OrderBy方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ReadPublicationTitleFromFile

 public static List<Publication> ReadPublicationTitleFromFile(string str, bool isDBLP)
 {
     IEnumerable<string> lines = File.ReadLines(Path.GetFullPath(str));
       var line = lines.Where(x => (x != ""));
       var results = new ConcurrentQueue<Publication>();
       Parallel.ForEach(line, l =>
       {
     Publication pub = Publication.FromHashCodeLine(l, isDBLP);
     if (pub != null)
     {
       results.Enqueue(pub);
     }
       });
       if(isDBLP)
     return results.OrderBy(x => x.index).ToList();
       else
     return results.OrderBy(x => x.arnetid).ToList();
 }
开发者ID:haihoi2,项目名称:KeywordSimilarity,代码行数:18,代码来源:Program.cs

示例2: ReadAuthorForMappingFromFile

 private static List<Author> ReadAuthorForMappingFromFile(string str, bool isDBLP)
 {
     IEnumerable<string> lines = File.ReadLines(Path.GetFullPath(str));
       var line = lines.Where(x => (x != ""));
       var results = new ConcurrentQueue<Author>();
       Parallel.ForEach(line, l =>
       {
     Author pub = Author.FromHashCodeLine(l, isDBLP);
     if (pub != null)
     {
       results.Enqueue(pub);
     }
       });
       if (isDBLP)
     return results.OrderBy(x => x.idAuthor).ToList();
       else
     return results.OrderBy(x => x.authorName.GetHashCode()).ToList();
 }
开发者ID:haihoi2,项目名称:KeywordSimilarity,代码行数:18,代码来源:Program.cs

示例3: Main

        public static void Main(string[] args)
        {
            const string AgendaUrl = "/Agenda";
            const string OutputDir =
                "D:\\Code\\BeyondResponsiveDesign\\BeyondResponsiveDesign.Menus\\images\\speakers";

            var imageClient = new HttpClient();
            var htmlClient = new HttpClient { BaseAddress = new Uri("http://www.dddeastanglia.com") };

            var htmlDoc = new HtmlDocument();
            htmlDoc.LoadHtml(htmlClient.GetStringAsync(AgendaUrl).Result);

            var speakerLinks =
                htmlDoc.DocumentNode.Descendants("a")
                    .Where(o => o.Attributes.Contains("class") && o.Attributes["class"].Value == "speakerName");

            var speakers = new ConcurrentQueue<Speaker>();
            Task.WaitAll(speakerLinks.Select(link => Task.Run(async () =>
                {
                    var href = link.Attributes["href"].Value;
                    var speakerPage = new HtmlDocument();
                    speakerPage.LoadHtml(await htmlClient.GetStringAsync(href));

                    var container =
                        speakerPage.DocumentNode.Descendants("div")
                            .First(
                                o => o.Attributes.Contains("class") && o.Attributes["class"].Value.Contains("speaker"));

                    var titleElement = container.Descendants("h3").First();
                    var linkElements = container.Descendants("section").First().Descendants("p");
                    var paragraphElements = container.Elements("p");
                    var sessionLinkElements = container.Element("ul").Descendants("a");

                    var id = int.Parse(href.Split('/').Last());
                    var name = titleElement.Element("#text").InnerHtml;
                    var bio = string.Join(string.Empty, paragraphElements.Select(o => o.InnerHtml));
                    var links = (from linkElement in linkElements
                                 let icon = linkElement.Descendants("i").First().Attributes["class"].Value
                                 let url = linkElement.Descendants("a").First().Attributes["href"].Value
                                 select new Link { Icon = icon, Url = url }).ToList();

                    var sessions = new List<Session>();
                    foreach (var sessionLinkElement in sessionLinkElements)
                    {
                        var sessionHref = sessionLinkElement.Attributes["href"].Value;
                        var sessionId = int.Parse(sessionHref.Split('/').Last());
                        var title = sessionLinkElement.InnerText;

                        var sessionPage = new HtmlDocument();
                        sessionPage.LoadHtml(await htmlClient.GetStringAsync(sessionHref));

                        var abstractElement =
                            sessionPage.DocumentNode.Descendants("div")
                                .First(o => o.Attributes.Contains("class") && o.Attributes["class"].Value == "abstract");

                        var @abstract = abstractElement.InnerHtml;
                        sessions.Add(new Session { Id = sessionId, Title = title, Abstract = @abstract});
                    }

                    speakers.Enqueue(
                        new Speaker { Id = id, Name = name, Links = links, Bio = bio, Sessions = sessions });

                    var imageTag = titleElement.Descendants("img").First();
                    var imageUrl = imageTag.Attributes["src"].Value.Replace("s=50", "s=300");

                    var stream = await imageClient.GetStreamAsync(imageUrl);
                    var file = File.OpenWrite(string.Format("{0}\\{1}.jpg", OutputDir, id));
                    await stream.CopyToAsync(file);

                    file.Close();
                })).ToArray());

            var streamWriter = new StreamWriter(string.Format("{0}\\speakers.json", OutputDir));
            streamWriter.Write(JsonConvert.SerializeObject(speakers.OrderBy(o => o.Name)));
            streamWriter.Close();

            Console.WriteLine("Process completed, press any key to exit");
            Console.ReadKey();
        }
开发者ID:jonegerton,项目名称:BeyondResponsiveDesign,代码行数:79,代码来源:Program.cs


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