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


C# SemanticVersion.GetComparableVersionStrings方法代码示例

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


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

示例1: Exists

        public override bool Exists(string packageId, SemanticVersion version)
        {
            if (version != null)
            {
                // optimization: if we find the .nuspec file at "id.version"\"id.version".nuspec or 
                // the .nupkg file at "id.version"\"id.version".nupkg, consider it exists
                bool hasPackageDirectory = version.GetComparableVersionStrings()
                                                  .Select(v => packageId + "." + v)
                                                  .Any(path => FileSystem.FileExists(Path.Combine(path, path + Constants.PackageExtension)) ||
                                                               FileSystem.FileExists(Path.Combine(path, path + Constants.ManifestExtension)));
                if (hasPackageDirectory)
                {
                    return true;
                }
            }

            return FindPackage(packageId, version) != null;
        }
开发者ID:rikoe,项目名称:nuget,代码行数:18,代码来源:SharedPackageRepository.cs

示例2: FindPackage

        public IPackage FindPackage(string packageId, SemanticVersion version)
        {
            IQueryable<DataServicePackage> query = Context.CreateQuery<DataServicePackage>(PackageServiceEntitySetName).AsQueryable();

            foreach (string versionString in version.GetComparableVersionStrings())
            {
                try
                {
                    var packages = query.Where(p => p.Id == packageId && p.Version == versionString).ToArray();
                    Debug.Assert(packages == null || packages.Length <= 1);
                    if (packages.Length != 0)
                    {
                        return packages[0];
                    }
                }
                catch (DataServiceQueryException)
                {
                    // DataServiceQuery exception will occur when the (id, version) 
                    // combination doesn't exist.
                }
            }

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

示例3: FindPackage

        /// <summary>
        /// Find-Package
        /// </summary>
        /// <param name="packageId">package Id</param>
        /// <param name="version">package version</param>
        /// <param name="request"></param>
        /// <returns></returns>
        public IPackage FindPackage(string packageId, SemanticVersion version, NuGetRequest request)
        {
            if (string.IsNullOrWhiteSpace(packageId)) {
                return null;
            }

            request.Debug(Messages.DebugInfoCallMethod3, "HttpClientPackageRepository", "FindPackage", packageId);

            var query = packageId.MakeFindPackageByIdQuery(_nugetFindPackageIdQueryFormat);

            var packages = NuGetClient.FindPackage(query, request);

            //Usually versions has a limited number, ToArray should be ok.
            var versions = version.GetComparableVersionStrings().ToArray();

            //Will only enumerate packages once
            return packages.FirstOrDefault(package => packageId.Equals(package.Id, StringComparison.OrdinalIgnoreCase) && versions.Contains(package.Version,StringComparer.OrdinalIgnoreCase));
        }
开发者ID:OneGet,项目名称:NuGetProvider,代码行数:25,代码来源:HttpClientPackageRepository.cs

示例4: Exists

        public bool Exists(string packageId, SemanticVersion version)
        {
            IQueryable<DataServicePackage> query = Context.CreateQuery<DataServicePackage>(PackageServiceEntitySetName).AsQueryable();

            foreach (string versionString in version.GetComparableVersionStrings())
            {
                try
                {
                    var packages = query.Where(p => p.Id == packageId && p.Version == versionString)
                                    .Select(p => p.Id)      // since we only want to check for existence, no need to get all attributes
                                    .ToArray();

                    if (packages.Length == 1)
                    {
                        return true;
                    }
                }
                catch (DataServiceQueryException)
                {
                    // DataServiceQuery exception will occur when the (id, version) 
                    // combination doesn't exist.
                }
            }

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


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