private AtomFeed GenerateSyndicationFeed(NameValueCollection parameters) { UriBuilder myUrl = new UriBuilder("file:///test"); string[] queryString = Array.ConvertAll(parameters.AllKeys, key => String.Format("{0}={1}", key, parameters[key])); myUrl.Query = string.Join("&", queryString); AtomFeed feed = new AtomFeed("Discovery feed for " + this.Identifier, "This OpenSearch Service allows the discovery of the different items which are part of the " + this.Identifier + " collection" + "This search service is in accordance with the OGC 10-032r3 specification.", myUrl.Uri, myUrl.ToString(), DateTimeOffset.UtcNow); feed.Generator = "Terradue Web Server"; List<AtomItem> items = new List<AtomItem>(); // Load all avaialable Datasets according to the context PaginatedList<TestItem> pds = new PaginatedList<TestItem>(); int startIndex = 1; if (parameters["startIndex"] != null) startIndex = int.Parse(parameters["startIndex"]); pds.StartIndex = startIndex; pds.AddRange(Items); pds.PageNo = 1; if (parameters["startPage"] != null) pds.PageNo = int.Parse(parameters["startPage"]); pds.PageSize = 20; if (parameters["count"] != null) pds.PageSize = int.Parse(parameters["count"]); if (this.Identifier != null) feed.Identifier = this.Identifier; foreach (TestItem s in pds.GetCurrentPage()) { if (s is IAtomizable) { AtomItem item = (s as IAtomizable).ToAtomItem(parameters); if (item != null) items.Add(item); } else { string fIdentifier = s.Identifier; string fName = s.Name; string fText = (s.TextContent != null ? s.TextContent : ""); if (!string.IsNullOrEmpty(parameters["q"])) { string q = parameters["q"]; if (!(fName.Contains(q) || fIdentifier.Contains(q) || fText.Contains(q))) continue; } Uri alternate = new Uri("file:///test/search?count=0&id=" + fIdentifier); Uri id = new Uri(s.Id); AtomItem entry = new AtomItem(fIdentifier, fName, alternate, id.ToString(), s.Date); entry.PublishDate = s.Date.DateTime; entry.LastUpdatedTime = s.Date.DateTime; entry.Categories.Add(new SyndicationCategory(this.Identifier)); entry.Summary = new TextSyndicationContent(fName); entry.ElementExtensions.Add("identifier", "http://purl.org/dc/elements/1.1/", fIdentifier); items.Add(entry); } } feed.Items = items; var tr = pds.Count(); if (!string.IsNullOrEmpty(parameters["q"])) { tr = pds.Sum(i => (!(i.Name.Contains(parameters["q"]) || i.Identifier.Contains(parameters["q"]) || i.TextContent.Contains(parameters["q"]))) ? 0 : 1); } feed.TotalResults = tr; return feed; }