private static XElement FindEntry(XDocument document, string id, Version version)
{
return((from e in document.Root.Elements("package")
let entryId = e.GetOptionalAttributeValue("id")
let entryVersion = VersionUtility.ParseOptionalVersion(e.GetOptionalAttributeValue("version"))
where entryId != null && entryVersion != null
where id.Equals(entryId, StringComparison.OrdinalIgnoreCase) &&
version.Equals(entryVersion)
select e).FirstOrDefault());
}