Esempio n. 1
0
 private static XElement FindEntry(XDocument document, string id, SemanticVersion version) =>
 (!string.IsNullOrEmpty(id) ? (from e in document.Root.Elements("package")
                               let entryId = e.GetOptionalAttributeValue("id", null)
                                             let entryVersion = SemanticVersion.ParseOptionalVersion(e.GetOptionalAttributeValue("version", null))
                                                                    where (entryId != null) && (entryVersion != null)
                                                                    where id.Equals(entryId, StringComparison.OrdinalIgnoreCase) && ((version == null) || entryVersion.Equals(version))
                                                                select e).FirstOrDefault <XElement>() : null);
Esempio n. 2
0
        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());
        }
        public PackageName FindEntryWithLatestVersionById(string id)
        {
            if (String.IsNullOrEmpty(id))
            {
                throw new ArgumentException(CommonResources.Argument_Cannot_Be_Null_Or_Empty, "id");
            }

            XDocument document = GetDocument();

            if (document == null)
            {
                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)
                                                     orderby entryVersion descending
                                                     select new PackageName(entryId, entryVersion)).FirstOrDefault());
        }