本文整理汇总了C#中IGrouping.Count方法的典型用法代码示例。如果您正苦于以下问题:C# IGrouping.Count方法的具体用法?C# IGrouping.Count怎么用?C# IGrouping.Count使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IGrouping
的用法示例。
在下文中一共展示了IGrouping.Count方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShowItem
public void ShowItem(IGrouping<string, LootItem> lootItemGroup)
{
ItemCountText.text = String.Format("{0}X", lootItemGroup.Count().ToString());
LootItem lootItemSample = lootItemGroup.FirstElement();
ItemGroupNameText.text = lootItemSample.Name;
ItemGroupIcon.sprite = lootItemSample.IconSprite;
this.gameObject.SetActive(true);
}
示例2: BuildCustomer
private Customer BuildCustomer(IGrouping<int, Bet> bets)
{
Customer customer = new Customer();
customer.Id = bets.Key;
customer.TotalNumberOfBets = bets.Count();
customer.NumberOfSettledBets = bets.Count(bet => bet.BetStatus == BetStatus.Settled);
customer.NumberOfUnsettledBets = bets.Count(bet => bet.BetStatus == BetStatus.Unsettled);
customer.NumberOfWinningBets = bets.Count(bet => bet.BetStatus == BetStatus.Settled && bet.Win > 0);
customer.TotalSettledStake = bets.Where(bet => bet.BetStatus == BetStatus.Settled).Sum(bet => bet.Stake);
customer.TotalSettledWin = bets.Where(bet => bet.BetStatus == BetStatus.Settled).Sum(bet => bet.Win);
customer.TotalUnsettledStake = bets.Where(bet => bet.BetStatus == BetStatus.Unsettled).Sum(bet => bet.Stake);
customer.TotalUnsettledWin = bets.Where(bet => bet.BetStatus == BetStatus.Unsettled).Sum(bet => bet.Win);
_customerRiskCalculator.DetermineCustomerRisk(customer);
return customer;
}
示例3: HeroStatistic
public HeroStatistic(IGrouping<string, Match> group)
{
Hero = group.Key;
Matches = group.Count();
Wins = group.Where(m => m.Win).Count();
Losses = group.Where(m => m.Win == false).Count();
WinRatio = Convert.ToInt32((double)Wins / (double)Matches * 100);
TimePlayed = group.Select(g => g.Duration).Aggregate(TimeSpan.Zero, (subtotal, t) => subtotal.Add(t));
}
示例4: ShowItemGroup
public void ShowItemGroup(IGrouping<string, LootItem> lootItemGroup)
{
this.lootItemGroup = lootItemGroup;
GroupCountText.text = String.Format("{0}X", lootItemGroup.Count().ToString());
LootItem lootItemSample = lootItemGroup.FirstElement();
EffectDurationValueText.text = lootItemSample.EffectDuration.TotalSeconds.ToString();
PowerValueText.text = lootItemSample.PowerValue.ToString();
ItemGroupIcon.sprite = lootItemSample.IconSprite;
this.gameObject.SetActive(true);
}
示例5: Select
public PeerSubscription Select(IGrouping<string, PeerSubscription> potentials)
{
int current = -1;
lock (_currentOrdinals)
{
_currentOrdinals.TryGetValue(potentials.Key, out current);
current = (current + 1) % potentials.Count();
_currentOrdinals[potentials.Key] = current;
}
return potentials.ElementAt(current);
}
示例6: createTempFilesForProject
private IEnumerable<TempFile> createTempFilesForProject(IGrouping<string, RealtimeChangeMessage> project, List<string> projects)
{
var files = new List<TempFile>();
var file = TempFileFromFile(project.Key);
files.Add(new TempFile(null, file, project.Key));
var content = File.ReadAllText(project.Key);
if (project.Count(x => x.File != null) > 0)
project.ToList().ForEach(x => files.Add(updateContent(ref content, x)));
projects.ForEach(x => files.Add(updateProjectReference(ref content, x)));
File.WriteAllText(file, content);
Logger.WriteDebug("Project written " + file);
var relativePath = getRelativePath(_solution, project.Key);
_solutionContent = _solutionContent.Replace("\"" + relativePath + "\"", "\"" + getRelativePath(_solution, file) + "\"");
_solutionContent = _solutionContent.Replace("\"" + project.Key + "\"", "\"" + getRelativePath(_solution, file) + "\"");
Logger.WriteDebug(string.Format("Replacing {0} or {1} with {2}", relativePath, project.Key, file));
return files;
}
示例7: GroupOrMutant
private MutationNode GroupOrMutant(IGrouping<string, MutationTarget> byGroupGrouping)
{
if(byGroupGrouping.Count() == 1)
{
var mutationTarget = byGroupGrouping.First();
return new Mutant(mutationTarget.Id, mutationTarget);
}
else
{
return new MutantGroup(byGroupGrouping.Key,
from mutationTarget in byGroupGrouping
select new Mutant(mutationTarget.Id, mutationTarget)
);
}
}
示例8: NameCount
public NameCount(IGrouping<string, string> grouping)
{
Name = grouping.Key;
Count = grouping.Count();
}
示例9: IsSingleEvent
private static bool IsSingleEvent(IGrouping<DateTime, EconomicEvent> item)
{
return item.Count() == 1;
}
示例10: CreateMemberNameData
private PdfPTable CreateMemberNameData(PdfPTable table, IGrouping<string, ReportDataModel> data, string groupByClauseHeader, bool includeLeavingDetails, bool includeHeader)
{
if (includeHeader)
{
table.AddCell(GetHeaderCell(groupByClauseHeader));
table.AddCell(GetHeaderCell("Start Date"));
table.AddCell(GetHeaderCell("Gender"));
table.AddCell(GetHeaderCell("Ethnicity"));
table.AddCell(GetHeaderCell("Time At Smart"));
table.AddCell(GetHeaderCell("Agency"));
table.AddCell(GetHeaderCell("Project"));
if (includeLeavingDetails)
{
table.AddCell(GetHeaderCell("Date Of Leaving"));
table.AddCell(GetHeaderCell("Reason Of Leaving"));
}
}
var cnt = 0;
foreach (var item in data)
{
if (cnt <= 0)
{
var groupByClauseColumn = GetGroupRowCell(data.Key, _rowFont);
groupByClauseColumn.Rowspan = data.Count() + 2;
table.AddCell(groupByClauseColumn);
cnt++;
}
var stDt = item.StartDate.HasValue ? item.StartDate.Value.ToShortDateString() : string.Empty;
table.AddCell(new Phrase(stDt, _rowFont));
table.AddCell(new Phrase(item.GenderName, _rowFont));
table.AddCell(new Phrase(item.EthnicityName, _rowFont));
table.AddCell(new Phrase(item.TimeAtSmart, _rowFont));
table.AddCell(new Phrase(item.Agency, _rowFont));
table.AddCell(new Phrase(item.ProjectName, _rowFont));
if (includeLeavingDetails)
{
table.AddCell(new Phrase(item.ExitDate.HasValue ? item.ExitDate.Value.ToShortDateString() : null, _rowFont));
table.AddCell(new Phrase(item.ReasonOfLeaving, _rowFont));
}
}
return table;
}
示例11: WriteOperationMetadataGroup
/// <summary>
/// Writes a group of operation (all actions or all functions) that have the same "metadata".
/// </summary>
/// <remarks>
/// Expects the actions or functions scope to already be open.
/// </remarks>
/// <param name="operations">A grouping of operations that are all actions or all functions and share the same "metadata".</param>
private void WriteOperationMetadataGroup(IGrouping<string, ODataOperation> operations)
{
this.ValidateOperationMetadataGroup(operations);
this.JsonLightOutputContext.JsonWriter.WriteName(operations.Key);
bool useArray = operations.Count() > 1;
if (useArray)
{
this.JsonLightOutputContext.JsonWriter.StartArrayScope();
}
foreach (ODataOperation operation in operations)
{
this.WriteOperation(operation);
}
if (useArray)
{
this.JsonLightOutputContext.JsonWriter.EndArrayScope();
}
}
示例12: ValidateOperationMetadataGroup
/// <summary>
/// Validates a group of operations with the same context Uri.
/// </summary>
/// <param name="operations">Operations to validate.</param>
private void ValidateOperationMetadataGroup(IGrouping<string, ODataOperation> operations)
{
Debug.Assert(operations != null, "operations must not be null.");
Debug.Assert(operations.Any(), "operations.Any()");
Debug.Assert(operations.All(o => this.GetOperationMetadataString(o) == operations.Key), "The operations should be grouped by their metadata.");
if (operations.Count() > 1 && operations.Any(o => o.Target == null))
{
throw new ODataException(OData.Core.Strings.ODataJsonLightEntryAndFeedSerializer_ActionsAndFunctionsGroupMustSpecifyTarget(operations.Key));
}
foreach (IGrouping<string, ODataOperation> operationsByTarget in operations.GroupBy(this.GetOperationTargetUriString))
{
if (operationsByTarget.Count() > 1)
{
throw new ODataException(OData.Core.Strings.ODataJsonLightEntryAndFeedSerializer_ActionsAndFunctionsGroupMustNotHaveDuplicateTarget(operations.Key, operationsByTarget.Key));
}
}
}
示例13: UpdateBeeStatus
private void UpdateBeeStatus(IGrouping<BeeState, Bee> stateGroup)
{
status.Items.Add(string.Format("{0}: {1} bee{2}", stateGroup.Key, stateGroup.Count(), stateGroup.Count() == 1 ? string.Empty : "s"));
bool beesAreNotActive = stateGroup.Key.ToString() == "Idle" && stateGroup.Count() == _world.Bees.Count &&
_framesRun > 0;
if (beesAreNotActive)
EndSimulation();
}
示例14: NewWordCount
/// <summary>
/// Private method to be passed as linqs Select parameter. Lambda was too cumbersom
/// </summary>
/// <param name="wordCount"> The grouping result of the GroupBy method </param>
/// <returns> A new KeyValuePair of count values </returns>
private static KeyValuePair<string, int> NewWordCount(IGrouping<string, string> wordCount)
{
return new KeyValuePair<string, int>(wordCount.Key, wordCount.Count());
}
示例15: CreateQuizInfoForDb
private IEnumerable<QuizInfoForDb> CreateQuizInfoForDb(OrderingBlock orderingBlock, IGrouping<string, QuizAnswer> answers)
{
var ans = answers.Select(x => x.ItemId).ToList()
.Select(x => new QuizInfoForDb
{
QuizId = orderingBlock.Id,
IsRightAnswer = true,
ItemId = x,
Text = null,
QuizType = typeof(OrderingBlock),
QuizBlockScore = 0,
QuizBlockMaxScore = orderingBlock.MaxScore
}).ToList();
var isRightQuizBlock = answers.Count() == orderingBlock.Items.Length &&
answers.Zip(orderingBlock.Items, (answer, item) => answer.ItemId == item.GetHash()).All(x => x);
var blockScore = isRightQuizBlock ? orderingBlock.MaxScore : 0;
foreach (var info in ans)
info.QuizBlockScore = blockScore;
return ans;
}