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


C# IPackageRepository.FindPackage方法代码示例

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


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

示例1: GetPackagesToOpen

        protected IEnumerable<FileSystemPath> GetPackagesToOpen(IPackageRepository repository, string id, string version, bool recurse)
        {
            List<FileSystemPath> returnValue = new List<FileSystemPath>();

            var package = repository.FindPackage(id, new NuGet.SemanticVersion(version));
            if (package != null)
            {
                returnValue.Add(new FileSystemPath(RetrieveTemporaryPackageFile(package)));

                if (recurse)
                {
                    foreach (var dependency in Enumerable.SelectMany(package.DependencySets, d => d.Dependencies))
                    {
                        var childPackages = repository.FindPackagesById(dependency.Id);
                        var childPackage = childPackages.FindByVersion(dependency.VersionSpec).FirstOrDefault();
                        if (childPackage != null)
                        {
                            returnValue.AddRange(GetPackagesToOpen(repository, childPackage.Id, childPackage.Version.ToString(), recurse));
                        }
                    }
                }
            }

            return returnValue;
        }
开发者ID:modulexcite,项目名称:dotpeek-nupeek,代码行数:25,代码来源:OpenFromNuGetHandlerBase.cs

示例2: ResolvePackage

        /// <summary>
        /// Finds a package from the source repository that matches the id and version. 
        /// </summary>
        /// <param name="repository">The repository to find the package in.</param>
        /// <param name="packageId">Id of the package to find.</param>
        /// <param name="version">Version of the package to find.</param>
        /// <exception cref="System.InvalidOperationException">If the specified package cannot be found in the repository.</exception>
        public static IPackage ResolvePackage(IPackageRepository repository, string packageId, SemanticVersion version)
        {
            if (repository == null)
            {
                throw new ArgumentNullException("repository");
            }

            if (String.IsNullOrEmpty(packageId))
            {
                throw new ArgumentException(CommonResources.Argument_Cannot_Be_Null_Or_Empty, "packageId");
            }

            if (version == null)
            {
                throw new ArgumentNullException("version");
            }

            var package = repository.FindPackage(packageId, version);
            if (package == null)
            {
                throw new InvalidOperationException(
                        String.Format(CultureInfo.CurrentCulture,
                        NuGetResources.UnknownPackageSpecificVersion, packageId, version));
            }

            return package;
        }
开发者ID:aaasoft,项目名称:NuGet.Server,代码行数:34,代码来源:PackageHelper.cs

示例3: IsSatellitePackage

        public static bool IsSatellitePackage(
            IPackage package, 
            IPackageRepository repository,
            FrameworkName targetFramework,
            out IPackage runtimePackage)
        {
            // A satellite package has the following properties:
            //     1) A package suffix that matches the package's language, with a dot preceding it
            //     2) A dependency on the package with the same Id minus the language suffix
            //     3) The dependency can be found by Id in the repository (as its path is needed for installation)
            // Example: foo.ja-jp, with a dependency on foo

            runtimePackage = null;

            if (package.IsSatellitePackage())
            {
                string runtimePackageId = package.Id.Substring(0, package.Id.Length - (package.Language.Length + 1));
                PackageDependency dependency = package.FindDependency(runtimePackageId, targetFramework);

                if (dependency != null)
                {
                    runtimePackage = repository.FindPackage(runtimePackageId, versionSpec: dependency.VersionSpec, allowPrereleaseVersions: true, allowUnlisted: true);
                }
            }

            return runtimePackage != null;
        }
开发者ID:themotleyfool,项目名称:NuGet,代码行数:27,代码来源:PackageUtility.cs

示例4: InstallSemanticLoggingTextFile

 private async Task InstallSemanticLoggingTextFile(string installPath, IPackageRepository repository, IProgress<string> progress)
 {
     IPackage package = repository.FindPackage("EnterpriseLibrary.SemanticLogging.TextFile", new SemanticVersion(2, 0, 1406, 1));
     foreach (IPackageFile packageFile in package.GetLibFiles().ForNet45())
     {
         await CopyPackageFileToPath(installPath, packageFile);
     }
 }
开发者ID:ibebbs,项目名称:OneCog.SemanticLogging.Service.Utility,代码行数:8,代码来源:Installer.cs

示例5: InstallSemanticLoggingService

 private async Task InstallSemanticLoggingService(string installPath, IPackageRepository repository, IProgress<string> progress)
 {
     IPackage package = repository.FindPackage("EnterpriseLibrary.SemanticLogging.Service", new SemanticVersion(2, 0, 1406, 1));
     foreach (IPackageFile packageFile in package.GetToolFiles().Where(pf => string.IsNullOrWhiteSpace(Path.GetDirectoryName(pf.EffectivePath))))
     {
         await CopyPackageFileToPath(installPath, packageFile);
     }
 }
开发者ID:ibebbs,项目名称:OneCog.SemanticLogging.Service.Utility,代码行数:8,代码来源:Installer.cs

示例6: ResolvePackage

        public static IPackage ResolvePackage(IPackageRepository sourceRepository, IPackageRepository localRepository, IPackageConstraintProvider constraintProvider,
            string packageId, SemanticVersion version, bool allowPrereleaseVersions)
        {
            if (String.IsNullOrEmpty(packageId))
            {
                throw new ArgumentException(CommonResources.Argument_Cannot_Be_Null_Or_Empty, "packageId");
            }

            IPackage package = null;

            // If we're looking for an exact version of a package then try local first
            if (version != null)
            {
                package = localRepository.FindPackage(packageId, version, allowPrereleaseVersions, allowUnlisted: true);
            }

            if (package == null)
            {
                // Try to find it in the source (regardless of version)
                // We use resolve package here since we want to take any constraints into account
                package = sourceRepository.FindPackage(packageId, version, constraintProvider, allowPrereleaseVersions, allowUnlisted: false);

                // If we already have this package installed, use the local copy so we don't 
                // end up using the one from the source repository
                if (package != null)
                {
                    package = localRepository.FindPackage(package.Id, package.Version, allowPrereleaseVersions, allowUnlisted: true) ?? package;
                }
            }

            // We still didn't find it so throw
            if (package == null)
            {
                if (version != null)
                {
                    throw new InvalidOperationException(
                        String.Format(CultureInfo.CurrentCulture,
                        NuGetResources.UnknownPackageSpecificVersion, packageId, version));
                }
                throw new InvalidOperationException(
                    String.Format(CultureInfo.CurrentCulture,
                    NuGetResources.UnknownPackage, packageId));
            }

            return package;
        }
开发者ID:xero-github,项目名称:Nuget,代码行数:46,代码来源:PackageHelper.cs

示例7: ResolvePackage

        /// <summary>
        /// Resolve package from online and local repository
        /// Used for Install-Package and Update-Package command to verify the specified package version exists in the repo.
        /// </summary>
        /// <param name="sourceRepository"></param>
        /// <param name="localRepository"></param>
        /// <param name="identity"></param>
        /// <param name="allowPrereleaseVersions"></param>
        /// <returns></returns>
        public static PackageIdentity ResolvePackage(SourceRepository sourceRepository, IPackageRepository localRepository,
            PackageIdentity identity, bool allowPrereleaseVersions)
        {
            string packageId = identity.Id;
            NuGetVersion nVersion = identity.Version;
            string version = identity.Version.ToNormalizedString();

            if (String.IsNullOrEmpty(identity.Id))
            {
                throw new ArgumentException(CommonResources.Argument_Cannot_Be_Null_Or_Empty, "packageId");
            }

            PackageIdentity resolvedIdentity = null;

            // If we're looking for an exact version of a package then try local first
            if (version != null)
            {
                SemanticVersion sVersion = new SemanticVersion(version);
                IPackage package = localRepository.FindPackage(packageId, sVersion, allowPrereleaseVersions, allowUnlisted: false);
                if (package != null)
                {
                    resolvedIdentity = new PackageIdentity(packageId, NuGetVersion.Parse(package.Version.ToString()));
                }
            }

            if (resolvedIdentity == null)
            {
                if (nVersion == null)
                {
                    throw new InvalidOperationException(
                        String.Format(CultureInfo.CurrentCulture,
                        NuGetResources.UnknownPackageSpecificVersion, packageId, version));
                }
                else
                {
                    Task<JObject> task = sourceRepository.GetPackageMetadata(packageId, nVersion);
                    JObject package = task.Result;
                    if (package == null)
                    {
                        if (version != null)
                        {
                            throw new InvalidOperationException(
                                String.Format(CultureInfo.CurrentCulture,
                                NuGetResources.UnknownPackageSpecificVersion, packageId, version));
                        }
                        throw new InvalidOperationException(
                            String.Format(CultureInfo.CurrentCulture,
                            NuGetResources.UnknownPackage, packageId));
                    }
                    else
                    {
                        resolvedIdentity = new PackageIdentity(packageId, nVersion);
                    }
                }
            }

            return resolvedIdentity;
        }
开发者ID:sistoimenov,项目名称:NuGet2,代码行数:67,代码来源:PackageRepositoryHelper.cs

示例8: ResolvePackage

        private IPackage ResolvePackage(IPackageRepository localRepository, IPackageRepository sourceRepository, IPackageConstraintProvider constraintProvider,
                                       string packageId, SemanticVersion version, bool allowPrereleaseVersions)
        {
            if (String.IsNullOrEmpty(packageId))
            {
                throw new ArgumentException("Argument cannot be null or empty: {0}", "packageId");
            }

            IPackage package = null;

            // If we're looking for an exact version of a package then try local first (where local is typically the target .\packages directory)
            if (version != null)
            {
                package = localRepository.FindPackage(packageId, version, allowPrereleaseVersions, allowUnlisted: true);
            }

            //Check the object cache first, else fall back to on disk cache then remote call
            if (package == null && !_cache.TryCacheHitByVersion(packageId, version, out package))
            {
                //Check the cache first by splitting the AggregateRepository into local/remote and querying seperately
                package = package ?? FindPackageInAggregateLocalSources(sourceRepository, constraintProvider, packageId, version, allowPrereleaseVersions);

                //If we are still null, check the remote for the package....
                package = package ?? FindPackageInRemoteSources(sourceRepository, packageId, version);
            }

            //Not sure if this is still necessary, as we already know the version....
            if (package != null)
            {
                package = localRepository.FindPackage(package.Id, package.Version, allowPrereleaseVersions, allowUnlisted: true) ?? package;
            }


            // We still didn't find it so throw
            if (package == null)
            {
                if (version != null)
                {
                    throw new InvalidOperationException( String.Format("Unknown Package Version: {0} {1}", packageId, version));
                }
                throw new InvalidOperationException(String.Format("Unknown Package Id: {0}", packageId));
            }

            return package;
        }
开发者ID:modulexcite,项目名称:NuGet.Extensions,代码行数:45,代码来源:PackageResolutionManager.cs

示例9: InstallTransientFaultHandlingData

        private async Task InstallTransientFaultHandlingData(string installPath, IPackageRepository repository, IProgress<string> progress)
        {
            IPackage package = repository.FindPackage("EnterpriseLibrary.TransientFaultHandling.Data");

            progress.Report(string.Format("Installing '{0}'", package.GetFullName()));

            foreach (IPackageFile packageFile in package.GetLibFiles().ForNet45())
            {
                await CopyPackageFileToPath(installPath, packageFile);
            }
        }
开发者ID:ibebbs,项目名称:OneCog.SemanticLogging.Service.Utility,代码行数:11,代码来源:Installer.cs

示例10: InstallNewtonsoftJson

        private async Task InstallNewtonsoftJson(string installPath, IPackageRepository repository, IProgress<string> progress)
        {
            IPackage package = repository.FindPackage("Newtonsoft.Json", SemanticVersion.ParseOptionalVersion("5.0.8"));

            progress.Report(string.Format("Installing '{0}'", package.GetFullName()));

            foreach (IPackageFile packageFile in package.GetLibFiles().ForNet45())
            {
                await CopyPackageFileToPath(installPath, packageFile);
            }
        }
开发者ID:ibebbs,项目名称:OneCog.SemanticLogging.Service.Utility,代码行数:11,代码来源:Installer.cs

示例11: ResolvePackage

        public static IPackage ResolvePackage(IPackageRepository sourceRepository, IPackageRepository localRepository, string packageId, Version version)
        {
            if (String.IsNullOrEmpty(packageId)) {
                throw new ArgumentException(CommonResources.Argument_Cannot_Be_Null_Or_Empty, "packageId");
            }

            IPackage package = null;

            // If we're looking for an exact version of a package then try local first
            if (version != null) {
                package = localRepository.FindPackage(packageId, version);
            }

            if (package == null) {
                // Try to find it in the source (regardless of version)
                package = sourceRepository.FindPackage(packageId, version: version);

                // If we already have this package installed, use the local copy so we don't
                // end up using the one from the source repository
                if (package != null) {
                    package = localRepository.FindPackage(package.Id, package.Version) ?? package;
                }
            }

            // We still didn't find it so throw
            if (package == null) {
                if (version != null) {
                    throw new InvalidOperationException(
                        String.Format(CultureInfo.CurrentCulture,
                        NuGetResources.UnknownPackageSpecificVersion, packageId, version));
                }
                throw new InvalidOperationException(
                    String.Format(CultureInfo.CurrentCulture,
                    NuGetResources.UnknownPackage, packageId));
            }

            return package;
        }
开发者ID:larsw,项目名称:nuget,代码行数:38,代码来源:PackageHelper.cs

示例12: GetPackagesToBeReinstalled

        /// <summary>
        /// Get the list of packages to be reinstalled given the project framework, packageReferences and the localRepository
        /// </summary>
        /// <param name="projectFramework">Current target framework of the project</param>
        /// <param name="packageReferences">List of package references in the project from which packages to be reinstalled are determined</param>
        /// <param name="localRepository">Project for which packages to be reinstalled are determined</param>
        /// <returns></returns>
        internal static List<IPackage> GetPackagesToBeReinstalled(FrameworkName projectFramework, IEnumerable<PackageReference> packageReferences, IPackageRepository localRepository)
        {
            Debug.Assert(projectFramework != null);
            Debug.Assert(packageReferences != null);
            Debug.Assert(localRepository != null);

            List<IPackage> packagesToBeReinstalled = new List<IPackage>();

            foreach (PackageReference packageReference in packageReferences)
            {
                IPackage package = localRepository.FindPackage(packageReference.Id);
                if (package != null && ShouldPackageBeReinstalled(projectFramework, packageReference.TargetFramework, package))
                {
                    packagesToBeReinstalled.Add(package);
                }
            }

            return packagesToBeReinstalled;
        }
开发者ID:Newtopian,项目名称:nuget,代码行数:26,代码来源:ProjectRetargetingUtility.cs

示例13: NugetService

        public NugetService(Solution solution, IEnumerable<string> remoteFeeds)
        {
            var repoBuilder = new PackageRepositoryBuilder();

            _remoteRepository = repoBuilder.BuildRemote(remoteFeeds);
            _localRepository = repoBuilder.BuildLocal(solution.PackagesFolder());
            _sourceRepository = repoBuilder.BuildSource(_remoteRepository, _localRepository);

            _fileSystem = new PhysicalFileSystem(solution.PackagesFolder());
            _pathResolver = new DefaultPackagePathResolver(_fileSystem);

            _console = new Console();
            _packageManager = new PackageManager(_sourceRepository, _pathResolver, _fileSystem, _localRepository){
                Logger = _console
            };

            _packages = new Cache<NugetDependency, IPackage>(dep =>
            {
                Install(dep);
                return _sourceRepository.FindPackage(dep.Name, new SemanticVersion(dep.Version));
            });
        }
开发者ID:wbinford,项目名称:ripple,代码行数:22,代码来源:NugetService.cs

示例14: IsSatellitePackage

        public static bool IsSatellitePackage(IPackage package, IPackageRepository repository, out IPackage runtimePackage)
        {
            // A satellite package has the following properties:
            //     1) A package suffix that matches the package's language, with a dot preceding it
            //     2) A dependency on the package with the same Id minus the language suffix
            //     3) The dependency can be found by Id in the repository (as its path is needed for installation)
            // Example: foo.ja-jp, with a dependency on foo

            runtimePackage = null;

            if (!String.IsNullOrEmpty(package.Language) && package.Id.EndsWith("." + package.Language, StringComparison.OrdinalIgnoreCase))
            {
                string runtimePackageId = package.Id.Substring(0, package.Id.Length - (package.Language.Length + 1));
                PackageDependency dependency = package.FindDependency(runtimePackageId);

                if (dependency != null)
                {
                    runtimePackage = repository.FindPackage(runtimePackageId);
                }
            }

            return runtimePackage != null;
        }
开发者ID:xero-github,项目名称:Nuget,代码行数:23,代码来源:PackageUtility.cs

示例15: InstallMicrosoftTraceEvent

        private async Task InstallMicrosoftTraceEvent(string installPath, IPackageRepository repository, IProgress<string> progress)
        {
            IPackage package = repository.FindPackage("Microsoft.Diagnostics.Tracing.TraceEvent", SemanticVersion.ParseOptionalVersion("1.0.15"));

            progress.Report(string.Format("Installing '{0}'", package.GetFullName()));

            foreach (IPackageFile packageFile in package.GetLibFiles().ForNet40())
            {
                await CopyPackageFileToPath(installPath, packageFile);
            }
            foreach (IPackageFile packageFile in package.GetLibFiles().ForNative())
            {
                await CopyPackageFileToPath(installPath, packageFile);
            }
        }
开发者ID:ibebbs,项目名称:OneCog.SemanticLogging.Service.Utility,代码行数:15,代码来源:Installer.cs


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