本文整理汇总了C#中IReadOnlyCollection.Count方法的典型用法代码示例。如果您正苦于以下问题:C# IReadOnlyCollection.Count方法的具体用法?C# IReadOnlyCollection.Count怎么用?C# IReadOnlyCollection.Count使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IReadOnlyCollection
的用法示例。
在下文中一共展示了IReadOnlyCollection.Count方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ComputeStatsForAllTime
public void ComputeStatsForAllTime(IReadOnlyCollection<Report> allReports, StatsViewModel vm)
{
var allCreated = allReports.Count(report => report.Status == ReportStatus.Created);
var allCompleted = allReports.Count(report => report.Status == ReportStatus.Completed);
var allProcessing = allReports.Count(report => report.Status == ReportStatus.Processing);
var allFailed = allReports.Count(report => report.Status == ReportStatus.Failure);
var allSummary = allReports.Count;
vm.AllTime = new StatsViewModel.AllTimeStats
{
Numbers = new StatsViewModel.Numbers
{
ReportsCount = allSummary,
ReportsCreated = allCreated,
ReportsCompleted = allCompleted,
ReportsProcessing = allProcessing,
ReportsFailed = allFailed
},
Percentages = new StatsViewModel.Percentages
{
AverageReportsCompleted = (double)allCompleted / (allSummary) * 100.0,
AverageReportsProcessing = (double)allProcessing / (allSummary) * 100.0,
AverageReportsFailure = (double)allFailed / (allSummary) * 100.0
}
};
}
示例2: Analyze
public IEnumerable<Fact> Analyze(IReadOnlyCollection<DiceRoll> statistics)
{
ICollection<Fact> facts = new Collection<Fact>();
var statisticsCount = statistics.Count(); //check for real diceroll
var successfulFact = new Fact
{
Description = "Count",
Divident = statisticsCount,
Divider = statisticsCount
};
facts.Add(successfulFact);
var sameFact = new Fact
{
Description = "Same",
Divident = statistics.Count(o => o.IsSameValue),
Divider = statisticsCount
};
facts.Add(sameFact);
var minSum = statistics.Min(o => o.Sum);
var maxSum = statistics.Max(o => o.Sum);
for (var i = minSum; i <= maxSum; i++)
{
var sumFact = new Fact
{
Description = "Sum " + i,
Divident = statistics.Count(o => o.Sum == i),
Divider = statisticsCount
};
facts.Add(sumFact);
}
//add single value fact generation
return facts;
}
示例3: UpdateMultiple
async Task<string[]> UpdateMultiple(IReadOnlyCollection<FileObjectMapping> objects,
IReadOnlyCollection<Package> packages,
IEnumerable<Uri> remotes) {
if (!objects.Any()) {
Repository.Log("No remote objects to resolve");
return new string[0];
}
Repository.Log("Resolving {0} remote objects for {1} packages from {2} remotes, please be patient..",
objects.Count(), packages.Count(), remotes.Count());
var relObjects = objects.OrderByDescending(x => Tools.FileUtil.SizePrediction(x.FilePath))
.Select(x => new FileFetchInfo(Repo.GetObjectSubPath(x), x.FilePath))
.ToArray();
StatusRepo.Reset(RepoStatus.Downloading, objects.Count());
StatusRepo.ProcessSize(GetExistingObjects(objects, packages), Repo.ObjectsPath, GetPackedSize(packages));
await Package.DownloadObjects(remotes, StatusRepo, relObjects, Repo.ObjectsPath).ConfigureAwait(false);
Repo.ReAddObject(objects.Select(x => x.Checksum).ToArray());
return relObjects.Select(x => x.FilePath).ToArray();
}
示例4: Checkout
// TODO: Async
public Package[] Checkout(IReadOnlyCollection<string> packageNames, bool? useFullNameOverride = null) {
StatusRepo.Reset(RepoStatus.CheckOut, packageNames.Count());
return packageNames.Select(package => Checkout(package, useFullNameOverride)).ToArray();
}
示例5: CreateBatch
private static void CreateBatch(IReadOnlyCollection<LogStatItem> records)
{
if (records == null)
{
ChangeThreadCount(-1);
return;
}
ALogger.LogInfo("CreateBatch: start create batch {0}", records.Count);
var batchCount = 0;
var totaltestcases = records.Count();
foreach (var item in records)
{
try
{
if ((batchCount % _flushqueueLimit) == 0)
{
ALogger.LogDebug("CreateBatch: processing item: {0} / {1}", batchCount, totaltestcases);
}
while (FlushQueueReady() || !_mre.WaitOne(_checkFileTimeoutMs))
{
if (!FlushQueueReady())
{
ALogger.LogTrace("CreateBatch: Queue is not ready wait for the next {0} ms", _checkFileTimeoutMs);
continue;
}
_flushQueue.EnQueue(item);
batchCount++;
break;
}
}
catch (Exception ex)
{
ALogger.LogError("CreateBatch: error processing item: {0}", ex.Message);
}
}
ALogger.LogInfo("CreateBatch: Done create batch {0}/{1}", batchCount, totaltestcases);
ChangeThreadCount(-1);
}
示例6: Checkout
public async Task<List<Package>> Checkout(IReadOnlyCollection<string> packageNames,
bool? useFullNameOverride = null) {
StatusRepo.Reset(RepoStatus.CheckOut, packageNames.Count());
var packages = new List<Package>();
foreach (var p in packageNames)
packages.Add(await CheckoutAsync(p, useFullNameOverride).ConfigureAwait(false));
return packages;
}
示例7: ImportReadOnlyCollectionService
public ImportReadOnlyCollectionService(IReadOnlyCollection<ISimpleObject> simpleObjects)
{
Assert.NotNull(simpleObjects);
Assert.Equal(5, simpleObjects.Count());
}