本文整理汇总了C#中IGrouping.OrderByDescending方法的典型用法代码示例。如果您正苦于以下问题:C# IGrouping.OrderByDescending方法的具体用法?C# IGrouping.OrderByDescending怎么用?C# IGrouping.OrderByDescending使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IGrouping
的用法示例。
在下文中一共展示了IGrouping.OrderByDescending方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Reduce
private static IEnumerable<SecurityAttributeDescriptor> Reduce(IGrouping<string, SecurityAttributeDescriptor> g)
{
var overrides = g.Where(d => d.Override != SecurityAttributeOverride.None).ToList();
switch (overrides.Count)
{
case 0:
yield return g.OrderByDescending(d => d.AttributeType).First();
break;
case 1:
var @override = overrides[0];
if (@override.Override == SecurityAttributeOverride.Add)
yield return new SecurityAttributeDescriptor(@override.AttributeType, @override.Target, @override.Signature);
break;
default:
throw new ArgumentException(string.Format("Conflicting overrides: {0}", overrides));
}
}
示例2: ComputeOffsetBetweenEvents
private DataAroundEvent[] ComputeOffsetBetweenEvents(IGrouping<string, DataAroundEvent>[] orderEventGroups, IGrouping<string, DataAroundEvent> midGroup)
{
// compute offset between each event to center group
DataAroundEvent[] repivotEvents;
repivotEvents = orderEventGroups.SelectMany(@group =>
@group.Select(d =>
{
var eventPicked = @group.OrderByDescending(e => e.EventDate).FirstOrDefault(g => g.EventDate > DateTime.Today.AddDays(-numberOfPointsAroundEvent));
int busDayDiff = 0;
if (eventPicked != null)
{
busDayDiff = BusDayDiff(midGroup.OrderByDescending(e => e.EventDate).First(x => x.EventDate > DateTime.Today.AddDays(-numberOfPointsAroundEvent)).EventDate, eventPicked.EventDate);
}
var ar = new DataAroundEvent(d.EventDate, d.Instrument, d.RawData, d.NumPointsAroundEvent, d.EventCode, busDayDiff)
{
PivotIndex = pivotIndex,
};
return ar;
})).ToArray();
return repivotEvents;
}
示例3: AssignReleaseStatus
/// <summary>
/// Assigns the release status.
/// </summary>
/// <param name="processItem">The process item.</param>
private static void AssignReleaseStatus(IGrouping<byte?, ProcessComplianceListItem> processItem)
{
var currentDate = DateTimeHelper.RetrieveCurrentDate();
var currentDateTime = DateTimeHelper.RetrieveCurrentDateTime();
////For past releases.
var processComplianceListItem = processItem.OrderByDescending(u => u.StartDate).FirstOrDefault(u => u.StartDate <= currentDateTime);
int missedArtifactsCount;
////When Artifacts are missed.
if (processComplianceListItem != null)
{
missedArtifactsCount = (from listItem in processComplianceListItem.Items where listItem.DueDate < currentDate && listItem.Status != (byte)ArtifactStatus.Completed select listItem).Count();
if (missedArtifactsCount > 0)
{
processComplianceListItem.ReleaseArtifactsMissedCount = missedArtifactsCount;
}
}
////When release has not been completed on EndDate.
if (processComplianceListItem != null && processComplianceListItem.ReleaseStatus.HasValue && processComplianceListItem.EndDate.HasValue && processComplianceListItem.EndDate < currentDateTime && !processComplianceListItem.ReleaseStatus.Equals((byte)ReleaseStatus.Completed))
{
processComplianceListItem.IsReleaseNotCompleted = true;
}
////For future releases.
processComplianceListItem = processItem.OrderBy(u => u.StartDate).FirstOrDefault(u => u.StartDate >= currentDateTime);
////When Artifacts are missed.
if (processComplianceListItem != null)
{
missedArtifactsCount = (from listItem in processComplianceListItem.Items where listItem.DueDate < currentDate && listItem.Status != (byte)ArtifactStatus.Completed select listItem).Count();
if (missedArtifactsCount > 0)
{
processComplianceListItem.ReleaseArtifactsMissedCount = missedArtifactsCount;
}
}
////When risk at release level for future releases.
if (processComplianceListItem != null && processComplianceListItem.Items.Any(u => u.ReleaseAtRiskFlag.HasValue && u.ReleaseAtRiskFlag.Value))
{
processComplianceListItem.IsReleaseAtRisk = true;
}
}