本文整理汇总了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);
}
}
示例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)
{