本文整理汇总了C#中IReadOnlyCollection.ToDictionary方法的典型用法代码示例。如果您正苦于以下问题:C# IReadOnlyCollection.ToDictionary方法的具体用法?C# IReadOnlyCollection.ToDictionary怎么用?C# IReadOnlyCollection.ToDictionary使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IReadOnlyCollection
的用法示例。
在下文中一共展示了IReadOnlyCollection.ToDictionary方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DependencySort
/// <summary>
/// Sort the specified resources in dependency order (most-dependent-first).
/// </summary>
/// <param name="resources">The resources to examine.</param>
/// <returns>
/// A read-only list of <see cref="Resource"/>s in dependency order.
/// </returns>
public static IReadOnlyList<Resource> DependencySort(IReadOnlyCollection<Resource> resources)
{
if (resources == null)
{
throw new ArgumentNullException(nameof(resources));
}
try
{
Dictionary<string, Resource> resourcesById = resources.ToDictionary(resource => resource.ResourceId);
AdjacencyGraph<Resource, Edge<Resource>> resourceDependencies = new AdjacencyGraph<Resource, Edge<Resource>>();
foreach (string resourceId in resourcesById.Keys)
{
Resource resource = resourcesById[resourceId];
if (!resourceDependencies.AddVertex(resource))
continue; // Already processed.
if (resource.DependsOn != null)
{
foreach (string dependsOnResourceId in resource.DependsOn)
{
Resource dependsOnResource;
if (!resourcesById.TryGetValue(dependsOnResourceId, out dependsOnResource))
{
throw new TemplateParserException($"Resource '{resourceId}' depends on non-existent resource '{dependsOnResourceId}'.");
}
resourceDependencies.AddEdge(new Edge<Resource>(resource, dependsOnResource));
}
}
}
return resourceDependencies.TopologicalSort().ToList();
}
catch (NonAcyclicGraphException ex)
{
throw new TemplateParserException("The template contains a circular dependency.", ex);
}
}
示例2: OpenTag
public OpenTag(string name, IReadOnlyCollection<Attribute> atributte)
{
Name = name;
Attributes = atributte.ToDictionary(atr => atr.Name, atr => atr.Value);
}
示例3: RuntimeEntityTemplateProvider
public RuntimeEntityTemplateProvider(IReadOnlyCollection<EntityTemplate> templates)
{
_templates = templates.ToDictionary(t => t.Key, t => t);
}
示例4: FetchAllRequestedPackages
private Task FetchAllRequestedPackages(IReadOnlyCollection<SpecificVersion> specificVersions) {
var i = 0;
var totalCount = specificVersions.Count;
var lObject = new object();
var allRemotes =
specificVersions.SelectMany(x => FindRemotesWithPackage(x.GetFullName())).Distinct().ToArray();
return
SyncEvilGlobal.DownloadHelper.DownloadFilesAsync(allRemotes, StatusRepo,
specificVersions.ToDictionary(x => new FileFetchInfo("packages/" + x.GetFullName() + ".json"),
x =>
(ITransferStatus)
new Status(x.GetFullName(), StatusRepo) {
RealObject = "packages/" + x + ".json",
OnComplete =
() => {
lock (lObject)
Progress.PackageFetching.Update(null, (++i).ToProgress(totalCount));
return TaskExt.Default;
}
}),
Repo.RootPath);
}