NuGet.LocalPackageRepository.FindPackage C# (CSharp) Метод

FindPackage() приватный Метод

private FindPackage ( IPackage>.Func openPackage, string packageId, SemanticVersion version ) : IPackage
openPackage IPackage>.Func
packageId string
version SemanticVersion
Результат IPackage
        internal IPackage FindPackage(Func<string, IPackage> openPackage, string packageId, SemanticVersion version)
        {
            var lookupPackageName = new PackageName(packageId, version);
            string packagePath;
            // If caching is enabled, check if we have a cached path. Additionally, verify that the file actually exists on disk since it might have moved.
            if (_enableCaching && 
                _packagePathLookup.TryGetValue(lookupPackageName, out packagePath) &&
                FileSystem.FileExists(packagePath))
            {
                // When depending on the cached path, verify the file exists on disk.
                return GetPackage(openPackage, packagePath);
            }

            // Lookup files which start with the name "<Id>." and attempt to match it with all possible version string combinations (e.g. 1.2.0, 1.2.0.0) 
            // before opening the package. To avoid creating file name strings, we attempt to specifically match everything after the last path separator
            // which would be the file name and extension.
            return (from path in GetPackageLookupPaths(packageId, version)
                    let package = GetPackage(openPackage, path)
                    where lookupPackageName.Equals(new PackageName(package.Id, package.Version))
                    select package).FirstOrDefault();
        }

Same methods

LocalPackageRepository::FindPackage ( string packageId, SemanticVersion version ) : IPackage

Usage Example

Пример #1
0
        public IPackageObject FindPackage(string path, IPackageReference packageRef)
        {
            var repository = new LocalPackageRepository(path);

            var package = packageRef.Version != null
                ? repository.FindPackage(packageRef.PackageId, new SemanticVersion(packageRef.Version, packageRef.SpecialVersion), true, true)
                : repository.FindPackage(packageRef.PackageId);

            return package == null ? null : new PackageObject(package, packageRef.FrameworkName);
        }
All Usage Examples Of NuGet.LocalPackageRepository::FindPackage