Ejemplo n.º 1
0
        public ODataPackage(ServerPackage package)
        {
            if (package == null)
            {
                throw new ArgumentNullException(nameof(package));
            }

            if (package.Version == null)
            {
                throw new ArgumentException("server package version is null");
            }
            Version           = package.Version.OriginalVersion;
            NormalizedVersion = package.Version.ToNormalizedString();

            Authors      = package.Authors;
            Owners       = package.Owners;
            IconUrl      = package.IconUrl;
            LicenseUrl   = package.LicenseUrl;
            ProjectUrl   = package.ProjectUrl;
            Dependencies = package.Dependencies;

            Id    = package.Id;
            Title = package.Title;
            RequireLicenseAcceptance = package.RequireLicenseAcceptance;
            Description             = package.Description;
            Summary                 = package.Summary;
            ReleaseNotes            = package.ReleaseNotes;
            Language                = package.Language;
            Tags                    = package.Tags;
            PackageHash             = package.PackageHash;
            PackageHashAlgorithm    = package.PackageHashAlgorithm;
            LastUpdated             = package.LastUpdated.UtcDateTime;
            Published               = package.Published.GetValueOrDefault().UtcDateTime;
            IsAbsoluteLatestVersion = package.IsAbsoluteLatestVersion;
            IsLatestVersion         = package.IsLatestVersion;
            IsPrerelease            = !package.IsReleaseVersion();
            Listed                  = package.Listed;
            DownloadCount           = package.DownloadCount;
            if (package.MinClientVersion != null)
            {
                MinClientVersion = package.MinClientVersion.ToNormalizedString();
            }

            //PackageSize = package.PackageSize;
            //Created = package.Created.UtcDateTime;
            //VersionDownloadCount = package.VersionDownloadCount;
        }
Ejemplo n.º 2
0
 public static ODataPackage AsODataPackage(this ServerPackage package, ClientCompatibility compatibility)
 {
     return(new ODataPackage
     {
         Id = package.Id,
         Version = package.Version.ToString(),
         NormalizedVersion = package.Version.ToNormalizedString(),
         IsPrerelease = !package.IsReleaseVersion(),
         Title = package.Title,
         Authors = string.Join(",", package.Authors),
         Owners = string.Join(",", package.Owners),
         IconUrl = package.IconUrl == null ? null : package.IconUrl.GetComponents(UriComponents.HttpRequestUrl, UriFormat.Unescaped),
         LicenseUrl = package.LicenseUrl == null ? null : package.LicenseUrl.GetComponents(UriComponents.HttpRequestUrl, UriFormat.Unescaped),
         ProjectUrl = package.ProjectUrl == null ? null : package.ProjectUrl.GetComponents(UriComponents.HttpRequestUrl, UriFormat.Unescaped),
         DownloadCount = package.DownloadCount,
         RequireLicenseAcceptance = package.RequireLicenseAcceptance,
         DevelopmentDependency = package.DevelopmentDependency,
         Description = package.Description,
         Summary = package.Summary,
         ReleaseNotes = package.ReleaseNotes,
         Published = package.Created.UtcDateTime,
         LastUpdated = package.LastUpdated.UtcDateTime,
         Dependencies = string.Join("|", package.DependencySets.SelectMany(ConvertDependencySetToStrings)),
         PackageHash = package.PackageHash,
         PackageHashAlgorithm = package.PackageHashAlgorithm,
         PackageSize = package.PackageSize,
         Copyright = package.Copyright,
         Tags = package.Tags,
         IsAbsoluteLatestVersion = compatibility.AllowSemVer2 ? package.SemVer2IsAbsoluteLatest : package.SemVer1IsAbsoluteLatest,
         IsLatestVersion = compatibility.AllowSemVer2 ? package.SemVer2IsLatest : package.SemVer1IsLatest,
         Listed = package.Listed,
         VersionDownloadCount = package.DownloadCount,
         MinClientVersion = package.MinClientVersion == null ? null : package.MinClientVersion.ToString(),
         Language = package.Language
     });
 }