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


C# List.Any方法代码示例

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


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

示例1: Main

        static void Main(string[] args)
        {
            if(args.Length < 1) return;
            string user = args[0];
            string broadcast = "";
            List<int> selectedVideos = new List<int>();
            bool downloadReplayOnly = false;
            bool isReverseOrder = false;

            var p = new OptionSet
            {
                {"b|broadcast=", "the name of broadcast.", v => broadcast = v},
                {"ds|downloadselected=", "only selected videos downloaded, seperate with comma (e.g. 1,2,7), start index is 0", v => selectedVideos = v.Split(',').Select(int.Parse).ToList()},
                {"ro|replayonly", "download only replay videos", v => downloadReplayOnly = v != null},
                {"r|reverse", "download reverse order", v => isReverseOrder = v != null}
            };

            p.Parse(args);
            if(string.IsNullOrEmpty(user)) return;
            bool downloadSingle = !string.IsNullOrEmpty(broadcast);
            bool downloadSelectedVideos = selectedVideos.Any();
            if(downloadSelectedVideos && downloadSingle) return;

            PDownload pDownload = new PDownload
            {
                User = user,
                Broadcast = broadcast,
                SelectedVideos = selectedVideos,
                DownloadLiveStream = !downloadReplayOnly,
                IsReverseOrder = isReverseOrder
            };
            using (VideoDownloader videoDownloader = new VideoDownloader())
            {
                if (downloadSingle)
                    videoDownloader.DownloadVideos(pDownload);
                else
                    videoDownloader.DownloadAllVideos(pDownload);
            }
        }
开发者ID:suphero,项目名称:PDownloader,代码行数:39,代码来源:Program.cs

示例2: ConnectionsManagerThread


//.........这里部分代码省略.........
                            }
                        }

                        {
                            var array = _settings.DiffusionBlocksRequest.ToArray();
                            _random.Shuffle(array);

                            int count = 256;

                            for (int i = 0; i < count && i < array.Length; i++)
                            {
                                diffusionBlocksList.Add(array[i]);
                            }
                        }
                    }

                    _random.Shuffle(diffusionBlocksList);

                    {
                        var diffusionBlocksDictionary = new Dictionary<Node, HashSet<Key>>();

                        foreach (var key in diffusionBlocksList)
                        {
                            try
                            {
                                var requestNodes = new List<Node>();

                                // 自分より距離が遠いノードにもアップロードを試みる。
                                foreach (var node in Kademlia<Node>.Search(key.Hash, otherNodes, 3))
                                {
                                    requestNodes.Add(node);
                                }

                                if (requestNodes.Any(n => _messagesManager[n].StockBlocks.Contains(key)))
                                {
                                    _settings.UploadBlocksRequest.Remove(key);
                                    _settings.DiffusionBlocksRequest.Remove(key);

                                    continue;
                                }

                                for (int i = 0; i < requestNodes.Count; i++)
                                {
                                    HashSet<Key> collection;

                                    if (!diffusionBlocksDictionary.TryGetValue(requestNodes[i], out collection))
                                    {
                                        collection = new HashSet<Key>();
                                        diffusionBlocksDictionary[requestNodes[i]] = collection;
                                    }

                                    collection.Add(key);
                                }
                            }
                            catch (Exception e)
                            {
                                Log.Error(e);
                            }
                        }

                        lock (_diffusionBlocksDictionary.ThisLock)
                        {
                            _diffusionBlocksDictionary.Clear();

                            foreach (var pair in diffusionBlocksDictionary)
                            {
开发者ID:networkelements,项目名称:Library,代码行数:67,代码来源:ConnectionsManager.cs


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