当前位置: 首页>>代码示例>>C#>>正文


C# IReadOnlyCollection.ToDictionary方法代码示例

本文整理汇总了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);
            }
        }
开发者ID:bernard357,项目名称:CaaSDeploy,代码行数:48,代码来源:ResourceDependencies.cs

示例2: OpenTag

 public OpenTag(string name, IReadOnlyCollection<Attribute> atributte)
 {
     Name = name;
     Attributes = atributte.ToDictionary(atr => atr.Name, atr => atr.Value);
 }
开发者ID:EmptyBucket,项目名称:HtmlParserCombinators,代码行数:5,代码来源:OpenTag.cs

示例3: RuntimeEntityTemplateProvider

 public RuntimeEntityTemplateProvider(IReadOnlyCollection<EntityTemplate> templates)
 {
     _templates = templates.ToDictionary(t => t.Key, t => t);
 }
开发者ID:Simie,项目名称:OpenAOE,代码行数:4,代码来源:RuntimeEntityTemplateProvider.cs

示例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);
 }
开发者ID:SIXNetworks,项目名称:withSIX.Desktop,代码行数:22,代码来源:PackageManager.cs


注:本文中的IReadOnlyCollection.ToDictionary方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。