本文整理汇总了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;
}
示例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);
}