Skip to content
This repository has been archived by the owner on Dec 18, 2017. It is now read-only.

Commit

Permalink
Use 'Id' element in OData as accurate package Id and 'title' as fallback
Browse files Browse the repository at this point in the history
  • Loading branch information
ChengTian committed Sep 17, 2014
1 parent d28ad9d commit 64edf76
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,15 @@ public async Task<IEnumerable<PackageInfo>> FindPackagesByIdAsyncCore(string id)
public PackageInfo BuildModel(string id, XElement element)
{
var properties = element.Element(_xnameProperties);
var idElement = properties.Element(_xnameId);
var titleElement = element.Element(_xnameTitle);

return new PackageInfo
{
Id = element.Element(_xnameTitle).Value,
// If 'Id' element exist, use its value as accurate package Id
// Otherwise, use the value of 'title' if it exist
// Use the given Id as final fallback if all elements above don't exist
Id = idElement?.Value ?? titleElement?.Value ?? id,
Version = SemanticVersion.Parse(properties.Element(_xnameVersion).Value),
ContentUri = element.Element(_xnameContent).Attribute("src").Value,
};
Expand Down

0 comments on commit 64edf76

Please sign in to comment.