Beispiel #1
0
        private void FindVersionFromSource()
        {
            // try to find the xmlns and the correct version to use.
            XmlReader reader = _source.GetReader();

            while (!reader.EOF)
            {
                if (reader.NodeType == XmlNodeType.Element &&
                    reader.Name == "searchresults")
                {
                    _version = SearchVersion.Searchv1;
                }
                else if (reader.NodeType == XmlNodeType.Element)
                {
                    throw new XmlException("First element expected: searchresults!");
                }

                // check end conditions.
                if (_version != SearchVersion.Unknown)
                {
                    reader = null;
                    break;
                }

                reader.Read();
            }
        }
Beispiel #2
0
 private void FindVersionFromObject()
 {
     _version = SearchVersion.Unknown;
     if (_search_object is searchresults)
     {
         _version = SearchVersion.Searchv1;
     }
 }
Beispiel #3
0
 private void FindVersionFromObject()
 {
     this._version = SearchVersion.Unknown;
     if (!(this._search_object is searchresults))
     {
         return;
     }
     this._version = SearchVersion.Searchv1;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ManifestSearchResponse"/> class.
 /// </summary>
 /// <param name="packageIdentifier">Package Identifier.</param>
 /// <param name="packageName">Package Name.</param>
 /// <param name="publisher">Publisher.</param>
 /// <param name="searchVersion">Search Version.</param>
 public ManifestSearchResponse(
     string packageIdentifier    = null,
     string packageName          = null,
     string publisher            = null,
     SearchVersion searchVersion = null)
 {
     this.PackageIdentifier = packageIdentifier;
     this.PackageName       = packageName;
     this.Publisher         = publisher;
     this.Versions          = new SearchVersions()
     {
         searchVersion,
     };
 }
Beispiel #5
0
        private void FindVersionFromSource()
        {
            XmlReader reader = this._source.GetReader();

            while (!reader.EOF)
            {
                if (reader.NodeType == XmlNodeType.Element && reader.Name == "searchresults")
                {
                    this._version = SearchVersion.Searchv1;
                }
                else if (reader.NodeType == XmlNodeType.Element)
                {
                    throw new XmlException("First element expected: searchresults!");
                }
                if (this._version != SearchVersion.Unknown)
                {
                    break;
                }
                reader.Read();
            }
        }
Beispiel #6
0
 /// <summary>
 /// Creates a new search document based on an xml source.
 /// </summary>
 /// <param name="source"></param>
 public SearchDocument(IXmlSource source)
 {
     _source = source;
     _version = SearchVersion.Unknown;
 }
Beispiel #7
0
        private void FindVersionFromSource()
        {
            // try to find the xmlns and the correct version to use.
            XmlReader reader = _source.GetReader();
            while (!reader.EOF)
            {
                if (reader.NodeType == XmlNodeType.Element
                    && reader.Name == "searchresults")
                {
                    _version = SearchVersion.Searchv1;
                }
                else if (reader.NodeType == XmlNodeType.Element)
                {
                    throw new XmlException("First element expected: searchresults!");
                }

                // check end conditions.
                if (_version != SearchVersion.Unknown)
                {
                    reader = null;
                    break;
                }

                reader.Read();
            }
        }
Beispiel #8
0
 private void FindVersionFromObject()
 {
     _version = SearchVersion.Unknown;
     if (_search_object is searchresults)
     {
         _version = SearchVersion.Searchv1;
     }
 }
        /// <summary>
        /// This gets.
        /// </summary>
        /// <param name="manifest">Package Manifest.</param>
        /// <returns>Manifest Search Responses.</returns>
        public static List <ManifestSearchResponse> GetSearchVersions(PackageManifest manifest)
        {
            List <ManifestSearchResponse> response = new List <ManifestSearchResponse>();

            if (manifest == null)
            {
                return(response);
            }

            if (manifest.Versions == null)
            {
                response.Add(new ManifestSearchResponse(manifest.PackageIdentifier));
                return(response);
            }

            foreach (VersionExtended extended in manifest.Versions)
            {
                if (extended.Installers == null)
                {
                    response.Add(new ManifestSearchResponse(
                                     packageIdentifier: manifest.PackageIdentifier,
                                     packageName: extended.DefaultLocale.PackageName,
                                     publisher: extended.DefaultLocale.Publisher,
                                     packageVersion: extended.PackageVersion,
                                     channel: extended.Channel));
                }
                else
                {
                    PackageFamilyNames packageFamilyNames = new PackageFamilyNames();
                    ProductCodes       productCodes       = new ProductCodes();
                    foreach (Installer installer in extended.Installers)
                    {
                        if (!string.IsNullOrEmpty(installer.PackageFamilyName) && !packageFamilyNames.Contains(installer.PackageFamilyName))
                        {
                            packageFamilyNames.Add(installer.PackageFamilyName);
                        }

                        if (!string.IsNullOrEmpty(installer.ProductCode) && !productCodes.Contains(installer.ProductCode))
                        {
                            productCodes.Add(installer.ProductCode);
                        }
                    }

                    SearchVersion searchVersion = new SearchVersion
                    {
                        PackageVersion     = extended.PackageVersion,
                        Channel            = extended.Channel,
                        PackageFamilyNames = packageFamilyNames.Count > 0 ? packageFamilyNames : null,
                        ProductCodes       = productCodes.Count > 0 ? productCodes : null,
                    };

                    response.Add(new ManifestSearchResponse(
                                     packageIdentifier: manifest.PackageIdentifier,
                                     packageName: extended.DefaultLocale.PackageName,
                                     publisher: extended.DefaultLocale.Publisher,
                                     searchVersion: searchVersion));
                }
            }

            return(response);
        }
Beispiel #10
0
 private void FindVersionFromObject()
 {
     _version = SearchVersion.Unknown;
     if (_search_object is OsmSharp.Tools.Xml.Nominatim.Search.v1.searchresults)
     {
         _version = SearchVersion.Searchv1;
     }
 }
Beispiel #11
0
 /// <summary>
 /// Creates a new search document based on an xml source.
 /// </summary>
 /// <param name="source"></param>
 public SearchDocument(IXmlSource source)
 {
     _source  = source;
     _version = SearchVersion.Unknown;
 }