本文整理汇总了C#中IGrouping.ToArray方法的典型用法代码示例。如果您正苦于以下问题:C# IGrouping.ToArray方法的具体用法?C# IGrouping.ToArray怎么用?C# IGrouping.ToArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IGrouping
的用法示例。
在下文中一共展示了IGrouping.ToArray方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateDailyModel
private static DailyWeatherDataModel CreateDailyModel(IGrouping<DateTime, WeatherData> gr)
{
if (gr == null)
{
return null;
}
var items = gr.ToArray();
if (!items.Any())
{
return null;
}
var first = items.OrderByDescending(item => item.WeatherCode).First();
decimal minT = items.Min(d => d.Temperature);
decimal maxT = items.Max(d => d.Temperature);
decimal minP = items.Min(d => d.Pressure);
decimal maxP = items.Max(d => d.Pressure);
int minH = items.Min(d => d.Humidity);
int maxH = items.Max(d => d.Humidity);
return new DailyWeatherDataModel
{
DateTime = gr.Key,
MinTemperature = Convert.ToInt32(minT),
MaxTemperature = Convert.ToInt32(maxT),
MinPressure = Convert.ToInt32(minP),
MaxPressure = Convert.ToInt32(maxP),
MinHumidity = Convert.ToInt32(minH),
MaxHumidity = Convert.ToInt32(maxH),
Code = first.WeatherCode,
Description = first.WeatherDescription
};
}
示例2: DrawTestGroup
private void DrawTestGroup (string group, IGrouping<string, UnitTestResult> unitTestResult)
{
if (PrintFoldoutAndCheckIfCollapsed(group, unitTestResult.Key, unitTestResult)) return;
//puting this to the loop fails to order elements
var tests = unitTestResult.ToArray().OrderBy( t => t.Test.MethodName );
indentLevel++;
foreach (var testResult in tests)
{
var testName = testResult.Test.MethodName + '(' + testResult.Test.ParamName + ')';
PrintTest(testName, testResult);
}
indentLevel--;
}
示例3: MakeStubsForTypeMembers
private StringBuilder MakeStubsForTypeMembers(IGrouping<FixedType.Class, MemberImplInfo> stubInfos)
{
var writer = new System.IO.StringWriter();
var members = stubInfos.ToArray();
var isInterface = stubInfos.Key.IsInterface;
var ty = isInterface ? stubInfos.Key : _ty.GetMemType();
foreach (var memberImplInfo in members)
{
var member = memberImplInfo.Member;
var @explicit = memberImplInfo.Explicit;
var accessModifier = memberImplInfo.AccessModifier;
var implementationName = memberImplInfo.ImplementationName;
if (isInterface)
NUtils.GenerateMemberImplementation(writer, _source.FileIndex,
ty, member, @explicit, accessModifier, implementationName,
_cbGenerateXmlDoc.Checked);
else
{
// Генерируем override-методы. Для них нужно сформировать правильны модификатор доступа.
var am = (member.Attributes | NemerleModifiers.Override)
& ~(NemerleModifiers.Abstract | NemerleModifiers.Virtual | NemerleModifiers.SpecialName);
var acessMods = am.ToString().ToLower().Replace(",", "");
NUtils.GenerateMemberImplementation(writer, _source.FileIndex,
ty, member, false, acessMods, "",
_cbGenerateXmlDoc.Checked);
}
writer.WriteLine(); // разделяем члены пустой строкой
}
return writer.GetStringBuilder();
}
示例4: IncrementalHash
private void IncrementalHash(IGrouping<string, DupItem> quickHashGroup)
{
var groups = quickHashGroup.ToArray();
var first = groups.First();
var length = first.Size / BufferSize;
if (length == 0)
length = 1;
var position = 0;
for (var i = 0; i < length; i++)
{
position += BufferSize;
foreach (var group in groups.GroupBy(g => i == 0 ? string.Empty : g.HashSections[i - 1]))
{
foreach (var groupFile in group)
{
if (groupFile.HashSections == null)
groupFile.HashSections = new List<string>();
groupFile.HashSections.Add(HashTool.HashFile(groupFile.FileName, position, BufferSize));
}
}
}
foreach (var groupFile in groups)
{
groupFile.FullHash = string.Join(string.Empty, groupFile.HashSections);
}
}