NuGet.PackageReferenceFile.FindEntry C# (CSharp) Method

FindEntry() private static method

private static FindEntry ( System.Xml.Linq.XDocument document, string id, SemanticVersion version ) : System.Xml.Linq.XElement
document System.Xml.Linq.XDocument
id string
version SemanticVersion
return System.Xml.Linq.XElement
        private static XElement FindEntry(XDocument document, string id, SemanticVersion version)
        {
            if (String.IsNullOrEmpty(id))
            {
                return null;
            }

            return (from e in document.Root.Elements("package")
                    let entryId = e.GetOptionalAttributeValue("id")
                    let entryVersion = SemanticVersion.ParseOptionalVersion(e.GetOptionalAttributeValue("version"))
                    where entryId != null && entryVersion != null
                    where id.Equals(entryId, StringComparison.OrdinalIgnoreCase) && (version == null || entryVersion.Equals(version))
                    select e).FirstOrDefault();
        }