Beispiel #1
0
        public static async Task <List <Tweet> > SearchResponseToTweetsAsync(LinqToTwitter.Search result)
        {
            var tweets = new List <Tweet>();

            //ApplicationDbContext db2 = new ApplicationDbContext();

            //var listOfBadWords = db2.Blacklists.Select(w => w.Word);

            var listOfBadWords = GetAllBadWords();

            foreach (var item in result.Statuses)
            {
                var newerTweet = new Tweet();
                newerTweet.ImageUrl   = item.User.ProfileImageUrl;
                newerTweet.ScreenName = item.User.ScreenNameResponse;
                newerTweet.Text       = (Regex.Replace(item.Text, @"http[^\s]+", ""));


                foreach (var item2 in listOfBadWords)
                {
                    if (Regex.IsMatch(newerTweet.Text.ToLower(), item2))
                    {
                        newerTweet.Text = "Contains Bad Words";
                    }
                }

                newerTweet.PostTimeStamp = item.CreatedAt;
                newerTweet.Media         = item.ExtendedEntities.MediaEntities.FirstOrDefault(f => f.ExpandedUrl != null)?.ExpandedUrl.ToString();
                newerTweet.MediaImage    = item.ExtendedEntities.MediaEntities.FirstOrDefault(f => f.ExpandedUrl != null)?.MediaUrl.ToString();

                if (newerTweet.Text == (Regex.Replace(item.Text, @"http[^\s]+", "")).ToString())
                {
                    tweets.Add(newerTweet);
                }
            }
            return(tweets);
        }
        public void Search_Can_Serialize()
        {
            var search = new Search();
            var stringBuilder = new StringBuilder();

            var writer = XmlWriter.Create(stringBuilder);
            var xmlSerializer = new XmlSerializer(typeof(Search));
            xmlSerializer.Serialize(writer, search);
        }
 private void PesquisoAHashtag()
 {
     _pesquisa = _dao.Pesquisar(_hashtag);
 }