本文整理汇总了C#中IGrouping.Any方法的典型用法代码示例。如果您正苦于以下问题:C# IGrouping.Any方法的具体用法?C# IGrouping.Any怎么用?C# IGrouping.Any使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IGrouping
的用法示例。
在下文中一共展示了IGrouping.Any方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FindMaxVersionPlugin
private static IPlugin FindMaxVersionPlugin(IGrouping<string, IPlugin> plugins)
{
Debug.Assert(plugins.Any());
var maxVersionPlugin = plugins.First();
foreach (var plugin in plugins)
{
if (maxVersionPlugin.Version.CompareTo(plugin.Version) == -1)
{
LogManager.Warning(String.Format("Found previous version of plugin. Current version:" + PluginTostring(plugin) +
" Previous version: " + PluginTostring(maxVersionPlugin)));
maxVersionPlugin = plugin;
}
else
{
if (maxVersionPlugin != plugin)
{
LogManager.Warning(String.Format("Found previous version of plugin. Current version: " +
PluginTostring(maxVersionPlugin) +" Previous version: " + PluginTostring(plugin)));
}
}
}
return maxVersionPlugin;
}
示例2: AllContentDeleted
private static bool AllContentDeleted(IGrouping<DeletedParagraphCollectionType, BlockContentInfo> g)
{
var someNotDeleted = g.Any(b => ! AllParaContentIsDeleted(b.ThisBlockContentElement));
return ! someNotDeleted;
}
示例3: 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));
}
}
}
示例4: 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);
}
}
}
示例5: BuildClassConstructor
/// <summary>
/// Builds the class constructor.
/// </summary>
/// <param name="type">The type.</param>
/// <param name="sb">The string builder.</param>
/// <param name="options">The options.</param>
private static void BuildClassConstructor(IGrouping<string, PropertyBag> type, StringBuilder sb, JsGeneratorOptions options)
{
if (
type.Any(
p =>
(p.CollectionInnerTypes != null && p.CollectionInnerTypes.Any(q => !q.IsPrimitiveType)) ||
p.TransformablePropertyType == PropertyBag.TransformablePropertyTypeEnum.ReferenceType))
{
sb.AppendLine(
$"{options.OutputNamespace}.{Helpers.GetName(type.First().TypeName, options.ClassNameConstantsToRemove)} = function (cons, overrideObj) {{");
sb.AppendLine("\tif (!overrideObj) { overrideObj = { }; }");
sb.AppendLine("\tif (!cons) { cons = { }; }");
}
else if (type.First().TypeDefinition.IsEnum)
{
sb.AppendLine(
$"{options.OutputNamespace}.{Helpers.GetName(type.First().TypeName, options.ClassNameConstantsToRemove)} = {{");
}
else
{
sb.AppendLine(
$"{options.OutputNamespace}.{Helpers.GetName(type.First().TypeName, options.ClassNameConstantsToRemove)} = function (cons) {{");
sb.AppendLine("\tif (!cons) { cons = { }; }");
}
}
示例6: ActivityEditorVm
public ActivityEditorVm(
Model.Task task,
Dal.SoheilEdmContext uow,
IGrouping<Model.Activity, Model.StateStationActivity> ssaGroup)
: base(ssaGroup.Key)
{
Message = new Common.SoheilException.EmbeddedException();
if (!ssaGroup.Any())
{
Message.AddEmbeddedException("فعالیتی وجود ندارد");
return;
}
//make ProcessList self-aware of all changes
ProcessList.CollectionChanged += (s, e) =>
{
if (e.NewItems != null)
foreach (ProcessEditorVm processVm in e.NewItems)
{
ProcessList_Added(processVm);
}
};
//Add Choices
foreach (var choice in ssaGroup.OrderBy(ssa => ssa.ManHour))
{
Choices.Add(new ChoiceEditorVm(choice));
}
//Add existing processes
foreach (var process in task.Processes.Where(x => x.StateStationActivity.Activity.Id == ssaGroup.Key.Id))
{
ProcessList.Add(new ProcessEditorVm(process, Model, uow));
}
//Add process command
AddProcessCommand = new Commands.Command(o =>
{
DateTime dt;
if (GetTaskStart == null)
dt = ProcessList.Any() ?
ProcessList
.Where(x => x.ActivityModel.Id == ssaGroup.Key.Id)
.Max(x => x.Model.EndDateTime)
: task.StartDateTime;
else
dt = GetTaskStart();
var minMH = ssaGroup.Min(x => x.ManHour);
var processVm = new ProcessEditorVm(
new Model.Process
{
StartDateTime = dt,
EndDateTime = dt,
StateStationActivity = ssaGroup.First(x=>x.ManHour == minMH),
TargetCount = 0,
Task = task,
}, Model, uow);//activity Model is set here
ProcessList.Add(processVm);
processVm.IsSelected = true;
});
}