Example #1
0
        private static string GetFindPackageResult(string url, List <Package> packages, bool latestVersion)
        {
            string apiUri = url.Replace("&", "&amp;");
            Uri    uri    = new Uri(apiUri);

            DateTime updated = packages.Any()
                                   ? packages.OrderByDescending(p => p.DateUpdated).First().DateUpdated
                                   : DateTime.UtcNow;

            entry[] entries = latestVersion
                ? new[] { PackageDetails.GetPackageEntry(packages.FirstOrDefault(p => p.LatestVersion), uri) }
                : packages.Select(p => PackageDetails.GetPackageEntry(p, uri)).ToArray();

            feed feed = new feed
            {
                @base   = InvokeUrl + "/",
                id      = WebUtility.HtmlDecode(uri.ToString()),
                title   = new feedTitle("FindPackagesById"),
                updated = updated,
                link    = new feedLink("FindPackagesById", "FindPackagesById"),
                entry   = entries
            };

            XmlSerializer serializer = new XmlSerializer(typeof(feed));
            MemoryStream  ms         = new MemoryStream();

            serializer.Serialize(ms, feed);
            ms.Position = 0;
            return(new StreamReader(ms).ReadToEnd());
        }
Example #2
0
        private static string GetDetailsResult(Package package, Uri uri)
        {
            entry entry = PackageDetails.GetPackageEntry(package, uri);

            XmlSerializer serializer = new XmlSerializer(typeof(entry));
            MemoryStream  ms         = new MemoryStream();

            serializer.Serialize(ms, entry);
            ms.Position = 0;
            string result = new StreamReader(ms).ReadToEnd();

            return(result);
        }