Esempio n. 1
0
        private PackageQueryContext CreatePackageQueryContext(string id, string version, bool isSemVer2, bool isListed, bool deleted)
        {
            var parsedVersion     = NuGetVersion.Parse(version);
            var normalizedVersion = parsedVersion.ToNormalizedString();
            var fullVersion       = parsedVersion.ToFullString();
            var immutablePackage  = new ImmutablePackage(new PackageEntity
            {
                PackageKey          = 0,
                PackageRegistration = new PackageRegistrationEntity
                {
                    Id = id
                },
                Version        = normalizedVersion,
                Identity       = $"{id}/{normalizedVersion}",
                CatalogPackage = new CatalogPackageEntity
                {
                    Deleted = deleted,
                    FirstCommitTimestamp = 0,
                    LastCommitTimestamp  = 0,
                },
            });

            var nuspecContext = new NuspecContext(
                exists: false,
                document: null);

            return(new PackageQueryContext(immutablePackage, nuspecContext, isSemVer2, fullVersion, isListed));
        }
Esempio n. 2
0
        public async Task <PackageQueryContext> GetPackageQueryFromDatabasePackageContextAsync(PackageEntity package)
        {
            var immutablePackage   = new ImmutablePackage(package);
            var nuspecQueryContext = await GetNuspecQueryContextAsync(package);

            var isSemVer2 = NuspecUtility.IsSemVer2(nuspecQueryContext.Document);

            var    originalVersion = NuspecUtility.GetOriginalVersion(nuspecQueryContext.Document);
            string fullVersion     = null;

            if (NuGetVersion.TryParse(originalVersion, out var parsedVersion))
            {
                fullVersion = parsedVersion.ToFullString();
            }

            return(new PackageQueryContext(
                       immutablePackage,
                       nuspecQueryContext,
                       isSemVer2,
                       fullVersion,
                       package.V2Package?.Listed ?? package.CatalogPackage?.Listed ?? true));
        }