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


C# IPackagePathResolver.GetHashPath方法代码示例

本文整理汇总了C#中IPackagePathResolver.GetHashPath方法的典型用法代码示例。如果您正苦于以下问题:C# IPackagePathResolver.GetHashPath方法的具体用法?C# IPackagePathResolver.GetHashPath怎么用?C# IPackagePathResolver.GetHashPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IPackagePathResolver的用法示例。


在下文中一共展示了IPackagePathResolver.GetHashPath方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateLockFileLibrary

        public static LockFileLibrary CreateLockFileLibrary(LockFileLibrary previousLibrary, IPackagePathResolver resolver, IPackage package, string correctedPackageName = null)
        {
            var lockFileLib = new LockFileLibrary();

            // package.Id is read from nuspec and it might be in wrong casing.
            // correctedPackageName should be the package name used by dependency graph and
            // it has the correct casing that runtime needs during dependency resolution.
            lockFileLib.Name = correctedPackageName ?? package.Id;
            lockFileLib.Version = package.Version;
            lockFileLib.Sha512 = File.ReadAllText(resolver.GetHashPath(package.Id, package.Version));

            // If the shas are equal then do nothing
            if (previousLibrary?.Sha512 == lockFileLib.Sha512)
            {
                lockFileLib.Files = previousLibrary.Files;
                lockFileLib.IsServiceable = previousLibrary.IsServiceable;
            }
            else
            {
                lockFileLib.Files = package.GetFiles().Select(p => p.Path).ToList();
                var installPath = resolver.GetInstallPath(package.Id, package.Version);
                foreach (var filePath in lockFileLib.Files)
                {
                    if (!string.Equals(Path.GetExtension(filePath), ".dll", StringComparison.OrdinalIgnoreCase))
                    {
                        continue;
                    }

                    var assemblyPath = Path.Combine(installPath, filePath);
                    try
                    {
                        if (IsAssemblyServiceable(assemblyPath))
                        {
                            lockFileLib.IsServiceable = true;
                            break;
                        }
                    }
                    catch
                    {
                        // Just move on to the next file
                    }
                }
            }

            return lockFileLib;
        }
开发者ID:noahfalk,项目名称:dnx,代码行数:46,代码来源:LockFileUtils.cs

示例2: ResolvePackagePath

        private static string ResolvePackagePath(IPackagePathResolver defaultResolver,
                                                 IEnumerable<IPackagePathResolver> cacheResolvers,
                                                 IPackage package)
        {
            var defaultHashPath = defaultResolver.GetHashPath(package.Id, package.Version);

            foreach (var resolver in cacheResolvers)
            {
                var cacheHashFile = resolver.GetHashPath(package.Id, package.Version);

                // REVIEW: More efficient compare?
                if (File.Exists(defaultHashPath) &&
                    File.Exists(cacheHashFile) &&
                    File.ReadAllText(defaultHashPath) == File.ReadAllText(cacheHashFile))
                {
                    return resolver.GetInstallPath(package.Id, package.Version);
                }
            }

            return defaultResolver.GetInstallPath(package.Id, package.Version);
        }
开发者ID:jack4it,项目名称:KRuntime,代码行数:21,代码来源:NuGetDependencyResolver.cs


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