Esempio n. 1
0
        public PluginResult(RawPackageSearchMetadata p)
        {
            this.name       = p.Title;
            this.slug       = IdToSlug(p.Identity); //$"{p.Identity.Id},{p.Identity.}";
            this.downloaded = p.DownloadCount ?? 0;

            this.icons = new PhpArray {
                { "2x", p.IconUrl?.AbsoluteUri ?? string.Format(DefaultIconFormat, this.slug) }
            };

            this.short_description = p.Summary;
            this.sections          = new PhpArray {
                { "description", p.Description },
            };

            if (p.Published.HasValue)
            {
                this.added = p.Published.Value.ToString("R");
            }

            if (p.RawVersions != null && p.RawVersions.Length != 0)
            {
                var lastupdate = p.RawVersions
                                 .Select(x => x.Published.HasValue ? x.Published.Value : DateTime.MinValue)
                                 .Max();
                this.last_updated = lastupdate.ToString("R");
            }
            //this.active_installs = -1;
            //this.rating = ...

            this.tags     = new PhpArray((p.Tags ?? string.Empty).Split(new[] { ',' }));
            this.version  = p.Identity.Version.ToNormalizedString();
            this.author   = p.Authors;
            this.homepage = p.ProjectUrl?.AbsoluteUri;

            if (p.Identity is SourcePackageDependencyInfo srcpkg)
            {
                this.download_link = srcpkg.DownloadUri.AbsoluteUri;
            }
        }