本文整理汇总了C#中IGrouping.ToList方法的典型用法代码示例。如果您正苦于以下问题:C# IGrouping.ToList方法的具体用法?C# IGrouping.ToList怎么用?C# IGrouping.ToList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IGrouping
的用法示例。
在下文中一共展示了IGrouping.ToList方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetChartElement
private SeriesDateBasedElement GetChartElement(IGrouping<DateTime, Purchase> g)
{
var seriesElement = new SeriesDateBasedElement{ Argument = g.Key };
switch (chartValueType)
{
case ChartValueType.TotalCost:
var list = g.ToList();
seriesElement.Value = g.Sum(purchase => purchase.TotalCost);
break;
case ChartValueType.ItemCost:
list = g.ToList();
seriesElement.Value = g.Average(purchase => purchase.ItemCost);
break;
case ChartValueType.Number:
list = g.ToList();
seriesElement.Value = g.Sum(purchase => purchase.ItemsNumber);
break;
}
return seriesElement;
}
示例2: PackageFoundResult
public PackageFoundResult(IGrouping<string, IPackageInfo> packageInfos, PackageListOptions options, IEnumerable<IPackageInfo> currentPackages)
{
Options = options;
CurrentPackages = currentPackages;
Name = packageInfos.Key;
Packages = packageInfos.ToList();
}
示例3: BuildTracks
static List<AlbumTrack> BuildTracks(IGrouping<string, Track> gt)
{
var tracks = new List<AlbumTrack>();
gt.ToList().ForEach(t => {
var track = new AlbumTrack { Name = t.Name, PlayingTime = t.PlayingTime, TrackNumber = t.TrackNumber ?? 0, };
tracks.Add(track);
});
return tracks;
}
示例4: AirCondRow
public AirCondRow(IGrouping<Color, AirConditioner> groupCond)
{
var firstAir = groupCond.First();
Color = groupCond.Key;
AirConds = groupCond.ToList();
Count = AirConds.Count;
ColorName = firstAir.ColorName;
Mark = firstAir.Mark;
}
示例5: runTests
private void runTests(RunSettings settings, IGrouping<Type, MethodInfo> fixture)
{
log("Running fixture {0}", fixture.Key);
if (_channel != null)
_channel.TestStarted(fixture.Key.ToString());
new MSTestTestFixture(fixture.Key)
.Run(fixture.ToList()).ToList()
.ForEach(result =>
{
var item = getResult(settings, fixture, result);
_results.Add(item);
_channel.TestFinished(item);
});
}
示例6: runTests
private void runTests(RunSettings settings, IGrouping<Type, MethodInfo> fixture)
{
var list = fixture.ToList();
try
{
_logger.Write("Running fixture {0}", fixture.Key);
using (var runner = new MSTestTestRunner(fixture.Key))
{
list.Select(test => runner.Run(test)).ToList().ForEach(x => _results.Add(getResult(settings, fixture, x)));
}
}
catch (Exception ex)
{
list.ForEach(test => _results.Add(getResult(settings, fixture, new celer.Core.RunResult(test, false, false, ex, 0))));
}
}
示例7: CreateModuleDefinition
private static ModuleDefinition CreateModuleDefinition(IGrouping<string, TemplateInfo> t)
{
var moduleId = GetModuleId(t.Key);
var defaultTemplateCandidates = GetDefaultTemplateCandidates(moduleId);
var defaultTemplate = t.FirstOrDefault(a => defaultTemplateCandidates.Contains(a.Id));
var templates = t.ToList();
if (defaultTemplate == null && templates.Count == 1)
defaultTemplate = templates[0];
var skins = templates.Where(t1 => t1 != defaultTemplate).ToDictionary(GetSkinName);
if (defaultTemplate == null && skins.TryGetValue(string.Empty, out defaultTemplate))
skins.Remove(string.Empty);
return new ModuleDefinition(moduleId, defaultTemplate, skins);
}
示例8: 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;
}
示例9: parseProjectGroup
private static IAutoCompleteListItem parseProjectGroup(IGrouping<ulong, Toggl.TogglAutocompleteView> p)
{
var tasks = p.ToList();
if (tasks.Count == 1)
{
return ProjectItem.Create(tasks[0]);
}
var noTaskProject = tasks[0];
noTaskProject.TaskID = 0;
noTaskProject.TaskLabel = "";
return new ProjectCategory(
new CountedAutoCompleteView(tasks.Count - 1, noTaskProject),
tasks.Where(t => t.TaskID != 0)
.Select(TaskItem.Create)
.ToList<IAutoCompleteListItem>()
);
}
示例10: PackageFoundResult
public PackageFoundResult(IGrouping<string, IPackageInfo> packageInfos)
{
Name = packageInfos.Key;
Packages = packageInfos.ToList();
}
示例11: FixUserGroup
static void FixUserGroup(IGrouping<string, User> userGroup)
{
// sort them descending
var list = userGroup.ToList();
var users = (from l in list
orderby l.CreateDate
descending
select l).ToList();
Console.WriteLine("Processing {0}", users[0].Email);
List<UserContract> userConts = new List<UserContract>();
List<Building> userBuildings = new List<Building>();
List<UserInterest> landlordInterests = new List<UserInterest>();
List<UserInterest> tenantInterests = new List<UserInterest>();
List<SavedListing> userSavedListings = new List<SavedListing>();
for (int x = 1; x < users.Count; ++x)
{
userBuildings.AddRange((from b in buildings
where b.UserId == users[x].UserId
select b).ToList());
userConts.AddRange((from uc in userContracts
where uc.UserId == users[x].UserId
select uc).ToList());
tenantInterests.AddRange((from ui in userInterests
where ui.UserId == users[x].UserId
select ui).ToList());
landlordInterests.AddRange((from ui in userInterests
where ui.LandlordUserId == users[x].UserId
select ui).ToList());
userSavedListings.AddRange((from ui in savedListings
where ui.UserId == users[x].UserId
select ui).ToList());
}
Console.WriteLine("Fixing buildings and contracts...");
for (int x = 0; x < userBuildings.Count; ++x)
{
userBuildings[x].UserId = users[0].UserId;
}
for (int x = 0; x < userConts.Count; ++x)
{
userConts[x].UserId = users[0].UserId;
}
for (int x = 0; x < tenantInterests.Count; ++x)
{
tenantInterests[x].UserId = users[0].UserId;
}
for (int x = 0; x < landlordInterests.Count; ++x)
{
landlordInterests[x].LandlordUserId = users[0].UserId;
}
for (int x = 0; x < userSavedListings.Count; ++x)
{
userSavedListings[x].UserId = users[0].UserId;
}
context.SubmitChanges();
Console.WriteLine("Fixing Affiliate, Auth, and Roles");
var affiliateUsers = (from a in context.AffiliateUsers
where a.User.Email == users[0].Email &&
a.User.UserId != users[0].UserId
select a).ToList();
context.AffiliateUsers.DeleteAllOnSubmit(affiliateUsers);
var authTokens = (from a in context.AuthTokens
where a.User.Email == users[0].Email &&
a.User.UserId != users[0].UserId
select a).ToList();
context.AuthTokens.DeleteAllOnSubmit(authTokens);
var roleUsers = (from a in context.RoleUsers
where a.User.Email == users[0].Email &&
a.User.UserId != users[0].UserId
select a).ToList();
context.RoleUsers.DeleteAllOnSubmit(roleUsers);
var landlordInfo = (from a in context.LandlordInfos
where a.User.Email == users[0].Email &&
a.User.UserId != users[0].UserId
select a).ToList();
context.LandlordInfos.DeleteAllOnSubmit(landlordInfo);
var applicationInfo = (from a in context.ApplicationInfos
where a.User.Email == users[0].Email &&
a.User.UserId != users[0].UserId
select a).ToList();
context.ApplicationInfos.DeleteAllOnSubmit(applicationInfo);
var alerts = (from a in context.Alerts
where a.User.Email == users[0].Email &&
a.User.UserId != users[0].UserId
//.........这里部分代码省略.........
示例12: GetPayload
private APIPayload GetPayload(IGrouping<long, LibratoMetric> epochGroup)
{
var lines = epochGroup.ToList();
// Split the lines up into gauges and counters
var gauges = lines.Where(p => p.MetricType == LibratoMetricType.Gauge || p.MetricType == LibratoMetricType.Timing).ToArray();
var counts = lines.Where(p => p.MetricType == LibratoMetricType.Counter).ToArray();
var payload = new APIPayload();
payload.gauges = gauges;
payload.counters = counts;
payload.measure_time = epochGroup.Key;
payload.source = _source;
return payload;
}
示例13: Run
private async Task Run(IGrouping<string, Series> group, bool addNewItems, CancellationToken cancellationToken)
{
var tvdbId = group.Key;
// Todo: Support series by imdb id
var seriesProviderIds = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
seriesProviderIds[MetadataProviders.Tvdb.ToString()] = tvdbId;
var seriesDataPath = TvdbSeriesProvider.GetSeriesDataPath(_config.ApplicationPaths, seriesProviderIds);
var episodeFiles = Directory.EnumerateFiles(seriesDataPath, "*.xml", SearchOption.TopDirectoryOnly)
.Select(Path.GetFileNameWithoutExtension)
.Where(i => i.StartsWith("episode-", StringComparison.OrdinalIgnoreCase))
.ToList();
var episodeLookup = episodeFiles
.Select(i =>
{
var parts = i.Split('-');
if (parts.Length == 3)
{
int seasonNumber;
if (int.TryParse(parts[1], NumberStyles.Integer, _usCulture, out seasonNumber))
{
int episodeNumber;
if (int.TryParse(parts[2], NumberStyles.Integer, _usCulture, out episodeNumber))
{
return new Tuple<int, int>(seasonNumber, episodeNumber);
}
}
}
return new Tuple<int, int>(-1, -1);
})
.Where(i => i.Item1 != -1 && i.Item2 != -1)
.ToList();
var hasBadData = HasInvalidContent(group);
var anySeasonsRemoved = await RemoveObsoleteOrMissingSeasons(group, episodeLookup)
.ConfigureAwait(false);
var anyEpisodesRemoved = await RemoveObsoleteOrMissingEpisodes(group, episodeLookup)
.ConfigureAwait(false);
var hasNewEpisodes = false;
if (addNewItems && !group.Any(i => !i.IsInternetMetadataEnabled()))
{
var seriesConfig = _config.Configuration.MetadataOptions.FirstOrDefault(i => string.Equals(i.ItemType, typeof(Series).Name, StringComparison.OrdinalIgnoreCase));
if (seriesConfig == null || !seriesConfig.DisabledMetadataFetchers.Contains(TvdbSeriesProvider.Current.Name, StringComparer.OrdinalIgnoreCase))
{
hasNewEpisodes = await AddMissingEpisodes(group.ToList(), hasBadData, seriesDataPath, episodeLookup, cancellationToken)
.ConfigureAwait(false);
}
}
if (hasNewEpisodes || anySeasonsRemoved || anyEpisodesRemoved)
{
foreach (var series in group)
{
var directoryService = new DirectoryService(_logger, _fileSystem);
await series.RefreshMetadata(new MetadataRefreshOptions(directoryService), cancellationToken).ConfigureAwait(false);
await series.ValidateChildren(new Progress<double>(), cancellationToken, new MetadataRefreshOptions(directoryService), true)
.ConfigureAwait(false);
}
}
}
示例14: ProcessTransmissions
private static void ProcessTransmissions(CollarFile file, ArgosFile argos,
IGrouping<string, ArgosTransmission> group)
{
LogGeneralMessage(String.Format(" Start processing transmissions for Argos Id {0}", group.Key));
var platformId = group.Key;
var transmissions = group.ToList();
var first = transmissions.Min(t => t.DateTime);
var last = transmissions.Max(t => t.DateTime);
var databaseViews = new AnimalMovementViews();
var parameterSets =
databaseViews.GetTelonicsParametersForArgosDates(platformId, first, last)
.OrderBy(c => c.StartDate)
.ToList();
if (parameterSets.Count == 0)
{
var msg = String.Format("No Collar for ArgosId {0} from {1:g} to {2:g}",
platformId, first, last);
LogIssueForFile(file.FileId, msg, platformId, null, null, first, last);
return;
}
if (parameterSets[0].StartDate != null && first < parameterSets[0].StartDate)
{
var msg = String.Format("No Collar for ArgosId {0} from {1:g} to {2:g}",
platformId, first, parameterSets[0].StartDate);
LogIssueForFile(file.FileId, msg, platformId, null, null, first, parameterSets[0].StartDate);
}
int lastIndex = parameterSets.Count - 1;
if (parameterSets[lastIndex].EndDate != null && parameterSets[lastIndex].EndDate < last)
{
var msg = String.Format("No Collar for ArgosId {0} from {1:g} to {2:g}",
platformId, parameterSets[lastIndex].EndDate, last);
LogIssueForFile(file.FileId, msg, platformId, null, null, parameterSets[lastIndex].EndDate, last);
}
foreach (var parameterSet in parameterSets)
{
if (parameterSet.ParameterId == null ||
(parameterSet.CollarModel == "Gen3" && parameterSet.Gen3Period == null) ||
(parameterSet.CollarModel == "Gen4" && parameterSet.Format == null))
{
var start = parameterSet.StartDate ?? first;
var end = parameterSet.EndDate ?? last;
var msg = String.Format("No Telonics Parameters for Collar {0}/{3} from {1:g} to {2:g}",
parameterSet.CollarManufacturer, start, end, parameterSet.CollarId);
LogIssueForFile(file.FileId, msg, platformId, parameterSet.CollarManufacturer, parameterSet.CollarId, start, end);
continue;
}
try
{
ProcessParameterSet(file, argos, first, last, transmissions, parameterSet);
}
catch (Exception ex)
{
var message = String.Format(
"ERROR {0} adding Argos {1} transmissions from {2:g} to {3:g} to Collar {4}/{5}",
ex.Message, parameterSet.PlatformId, first, last,
parameterSet.CollarManufacturer, parameterSet.CollarId);
LogIssueForFile(file.FileId, message, parameterSet.PlatformId, parameterSet.CollarManufacturer,
parameterSet.CollarId, first, last);
}
}
LogGeneralMessage(" Finished processing transmissions");
}
示例15: _getPredicateLOKind
private LOPredicateConjunctionType _getPredicateLOKind(IGrouping<int, PredicatePartHelperObject> predicateGroup, BaseSentenceAlgorithmData sourceData)
{
var groupElements = predicateGroup.ToList();
// все номера рядов ОЧ из текущей группы без пустых
var uniformRows = groupElements.Select(x => x.UPRowNr).Distinct().ToList();
uniformRows.RemoveAll(x => x == string.Empty || x == UniformPartsFinalResults.UnknownRowNr);
// все номера рядов ОЧ, за исключением номеров текущей группы
var commonUniformRows = sourceData.HelperData.AsEnumerable()
.Where(x => x.Field<int>(HelperDataConjunctedPredicatesSourcePredicateParentId.Name) != int.Parse(predicateGroup.Key.ToString()))
.Select(x => x.Field<string>(HelperDataConjunctedPredicatesSourcePredicateUPRowNr.Name)).Distinct().ToList();
commonUniformRows.RemoveAll(x => x == "");
var predicateIndex = LOPredicateConjunctionType.NoConjunction;
if (uniformRows.Count == 0)
return predicateIndex;
// если хотя бы один номер ряда ОЧ найдется в общих
if (uniformRows.Count > 0)
{
var intersection = commonUniformRows.Intersect(uniformRows);
if (intersection.Count() == 1 && uniformRows.Count == 1)
predicateIndex = LOPredicateConjunctionType.OuterConjunction;
else
predicateIndex = LOPredicateConjunctionType.InnerConjunction;
// Добавляем проверку на и внешнее и внутреннее сочинение
if (intersection.Count() == 1 && uniformRows.Count > 1)
predicateIndex = LOPredicateConjunctionType.InnerAndOuterConjunction;
}
return predicateIndex;
}