Inheritance: IPackageVersionModel
示例#1
0
        public PackageViewModel Setup(PackageViewModel viewModel, Package package)
        {
            if (viewModel == null)
            {
                throw new ArgumentNullException(nameof(viewModel));
            }

            if (package == null)
            {
                throw new ArgumentNullException(nameof(package));
            }

            viewModel.FullVersion = NuGetVersionFormatter.ToFullString(package.Version);
            viewModel.IsSemVer2   = package.SemVerLevelKey == SemVerLevelKey.SemVer2;

            viewModel.Id      = package.PackageRegistration.Id;
            viewModel.Version = String.IsNullOrEmpty(package.NormalizedVersion) ?
                                NuGetVersionFormatter.Normalize(package.Version) :
                                package.NormalizedVersion;

            viewModel.Description                = package.Description;
            viewModel.ReleaseNotes               = package.ReleaseNotes;
            viewModel.IconUrl                    = _iconUrlProvider.GetIconUrlString(package);
            viewModel.LatestVersion              = package.IsLatest;
            viewModel.LatestVersionSemVer2       = package.IsLatestSemVer2;
            viewModel.LatestStableVersion        = package.IsLatestStable;
            viewModel.LatestStableVersionSemVer2 = package.IsLatestStableSemVer2;
            viewModel.DevelopmentDependency      = package.DevelopmentDependency;
            viewModel.LastUpdated                = package.Published;
            viewModel.Listed               = package.Listed;
            viewModel.DownloadCount        = package.DownloadCount;
            viewModel.Prerelease           = package.IsPrerelease;
            viewModel.FailedValidation     = package.PackageStatusKey == PackageStatus.FailedValidation;
            viewModel.Available            = package.PackageStatusKey == PackageStatus.Available;
            viewModel.Validating           = package.PackageStatusKey == PackageStatus.Validating;
            viewModel.Deleted              = package.PackageStatusKey == PackageStatus.Deleted;
            viewModel.PackageStatusSummary = GetPackageStatusSummary(package.PackageStatusKey, package.Listed);
            viewModel.TotalDownloadCount   = package.PackageRegistration.DownloadCount;

            return(viewModel);
        }
示例#2
0
        public PackageViewModel Create(Package package)
        {
            var viewModel = new PackageViewModel();

            return(Setup(viewModel, package));
        }