コード例 #1
0
        public void BeginSearch(SearchItem item)
        {                        
            var worker = new BackgroundWorker();
            worker.RunWorkerCompleted += (s,e) =>
            {
                try
                {
                    if (e.Result != null)
                    {
                        OnSearchComplete(e.Result as IEnumerable<SearchResult>);
                    }
                }
                catch(WebException ex)
                {
                    Debug.WriteLine(ex.Message);
                }
            };
            worker.DoWork += (s, e) =>
            {
                var client = new WebClient();
                var uri = new Uri(e.Argument.ToString());
                var xml = client.DownloadString(uri);
                if (!String.IsNullOrEmpty(xml))
                {
                    e.Result = ParseResults(xml, item);
                }
            };

            string url = String.Format(urlFormat, HttpUtility.UrlEncode(item.Phrase));
            worker.RunWorkerAsync(url);
        }        
コード例 #2
0
        private void RaiseCompleteEvent(SearchItem item)
        {
            var asm = Assembly.GetExecutingAssembly();
            var stream = asm.GetManifestResourceStream(_resourceName);

            if (stream != null && SearchComplete != null)
            {
                var doc = XDocument.Load(XmlReader.Create(stream));
                var converter = new TwitterSearchAtomConverter(doc, item);
                SearchComplete(this, new SearchCompleteEventArgs() { Results = converter.Convert().ToList()} );
            }
        }
コード例 #3
0
 public void DeleteTerm(SearchItem item)
 {
     _searchItems.Remove(item);
 }
コード例 #4
0
 public void AddCurrentWordAsSearchTerm()
 {
     _searchItems.AddSearchItem(SearchItem.CreateFrom(CurrentWord));
     CurrentWord = String.Empty;
 }
コード例 #5
0
 public TwitterSearchAtomConverter(XDocument atomDoc, SearchItem item)
 {
     _document = atomDoc;
     _item     = item;
 }
コード例 #6
0
 public TwitterSearchAtomConverter(XDocument atomDoc, SearchItem item)
 {
     _document = atomDoc;
     _item = item;
 }
コード例 #7
0
 private IEnumerable<SearchResult> ParseResults(string xml, SearchItem item)
 {
     var doc = XDocument.Parse(xml);
     var converter = new TwitterSearchAtomConverter(doc, item);
     return converter.Convert();
 }
コード例 #8
0
 public void DeleteTerm(SearchItem item)
 {
     _searchItems.Remove(item);
 }
コード例 #9
0
 public void BeginSearch(SearchItem item)
 {
     LastTermSeen = item.Phrase;
     RaiseCompleteEvent(item);
 }