Ejemplo n.º 1
0
        void request_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
        {
            SearchEventArgs args = new SearchEventArgs();

            if (e.Error == null)
            {
                string s = e.Result;
                DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(GeoIQ.Net.Data.Overlays));
                byte[] bytes = Encoding.ASCII.GetBytes(s);
                System.IO.MemoryStream stream = new System.IO.MemoryStream(bytes);
                GeoIQ.Net.Data.Overlays overlays = (GeoIQ.Net.Data.Overlays)serializer.ReadObject(stream);
                args._result = overlays;
            }
            else
            {
                args._error = e.Error;
            }
            if (this.AsynchSearchComplete != null)
                AsynchSearchComplete(args);
        }
Ejemplo n.º 2
0
        public SearchEventArgs ExecuteSearch(int limit, string terms, string model)
        {
            SearchEventArgs args = new SearchEventArgs();
            try
            {
                WebClient request = new WebClient();
                string url = String.Format("{0}/search.json?query={1}&limit={2}&model={3}", EndpointURI, terms, limit, model);
                setCredentials(request);

                Stream stream = request.OpenRead(url);
                DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(GeoIQ.Net.Data.Overlays));

                GeoIQ.Net.Data.Overlays overlays = (GeoIQ.Net.Data.Overlays)serializer.ReadObject(stream);
                args._result = overlays;
            }
            catch (Exception ex)
            {
                args._error = ex;
            }
            return args;
        }