Example #1
0
        public MediaEntity(Dictionary<String, object> media_entity)
        {
            id = media_entity.GetProp("id") as long?;
            id_str = media_entity.GetProp("id_str") as string;
            media_url = media_entity.GetProp("media_url") as string;
            media_url_https = media_entity.GetProp("media_url_https") as string;

            ObservableCollection<int> indices = new ObservableCollection<int>();

            foreach (int indice in media_entity.GetProp("indices") as object[])
            {
                indices.Add(indice);
            }

            url = new UrlEntity()
            {
                url = media_entity.GetProp("url") as string,
                display_url = media_entity.GetProp("display_url") as string,
                expanded_url = media_entity.GetProp("expanded_url") as string,
                indices = indices
            };

            type = media_entity.GetProp("type") as string;

            sizes = new Dictionary<string, MediaEntitySize>();
            Dictionary<String, object> tmp_sizes = media_entity.GetProp("sizes") as Dictionary<String, object>;

            foreach (object size in tmp_sizes)
            {
                KeyValuePair<String, object> pair = (KeyValuePair<String, object>)size;
                sizes.Add(pair.Key, new MediaEntitySize(pair.Value as Dictionary<String, object>));
            }
        }
Example #2
0
        public HashTagEntity(Dictionary<String, object> hash_tag_entity)
        {
            text = hash_tag_entity.GetProp("text") as string;
            indices = new ObservableCollection<int>();

            foreach (int indice in hash_tag_entity.GetProp("indices") as object[])
            {
                indices.Add(indice);
            }
        }
Example #3
0
        public UrlEntity(Dictionary<String, object> url_entity)
        {
            url = url_entity.GetProp("url") as string;
            display_url = url_entity.GetProp("display_url") as string;
            expanded_url = url_entity.GetProp("expanded_url") as string;
            indices = new ObservableCollection<int>();

            foreach (int indice in url_entity.GetProp("indices") as object[])
            {
                indices.Add(indice);
            }
        }
Example #4
0
        public UserMentionEntity(Dictionary<String, object> user_mention_entity)
        {
            id = user_mention_entity.GetProp("id") as long?;
            id_str = user_mention_entity.GetProp("id_str") as string;
            screen_name = user_mention_entity.GetProp("screen_name") as string;
            name = user_mention_entity.GetProp("name") as string;

            indices = new ObservableCollection<int>();
            foreach (int indice in user_mention_entity.GetProp("indices") as object[])
            {
                indices.Add(indice);
            }
        }
Example #5
0
        public TweetEntities(Dictionary<String, object> entities)
        {
            urls = entities.GetProp("urls") != null ?
                (from x in (entities.GetProp("urls") as object[])
                 select new UrlEntity(x as Dictionary<String, object>)).ToObservableCollection() : null;

            media = entities.GetProp("media") != null ?
                (from x in (entities.GetProp("media") as object[])
                 select new MediaEntity(x as Dictionary<String, object>)).ToObservableCollection() : null;

            user_mentions = entities.GetProp("user_mentions") != null ?
                (from x in (entities.GetProp("user_mentions") as object[])
                 select new UserMentionEntity(x as Dictionary<String, object>)).ToObservableCollection() : null;

            hashtags = entities.GetProp("hashtags") != null ?
                (from x in (entities.GetProp("hashtags") as object[])
                 select new HashTagEntity(x as Dictionary<String, object>)).ToObservableCollection() : null;
        }
Example #6
0
 public MediaEntitySize(Dictionary<String, object> media_entity_size)
 {
     w = media_entity_size.GetProp("w") as int?;
     resize = media_entity_size.GetProp("resize") as string;
     h = media_entity_size.GetProp("h") as int?;
 }
Example #7
0
        private void fillTweet(Dictionary<String, object> dTweet, bool cleanString = true)
        {
            if (dTweet.GetProp("id") != null)
            {
                created_at = DateTime.ParseExact(dTweet.GetProp("created_at") as string,
                    "ddd MMM dd HH:mm:ss zzzz yyyy", CultureInfo.InvariantCulture);
                id = dTweet.GetProp("id") as long?;
                id_str = dTweet.GetProp("id_str") as string;
                text = dTweet.GetProp("text") as string;
                source = dTweet.GetProp("source ") as string;
                truncated = dTweet.GetProp("truncated") as bool?;
                in_reply_to_status_id = dTweet.GetProp("in_reply_to_status_id") as int?;
                in_reply_to_status_id_str = dTweet.GetProp("in_reply_to_status_id_str") as string;
                in_reply_to_user_id = dTweet.GetProp("in_reply_to_user_id") as int?;
                in_reply_to_user_id_str = dTweet.GetProp("in_reply_to_user_id_str") as string;
                in_reply_to_screen_name = dTweet.GetProp("in_reply_to_screen_name") as string;
                user = User.Create(dTweet.GetProp("user") as object);
                // Create Geo
                var geo = dTweet.GetProp("geo");
                // Create Coordinates
                var coordinates = dTweet.GetProp("coordinates");
                // Create Place
                var place = dTweet.GetProp("place");
                // Create Contributors
                var contributors = dTweet.GetProp("contributors");
                retweet_count = dTweet.GetProp("retweet_count") as int?;
                entities = new TweetEntities(dTweet["entities"] as Dictionary<String, object>);
                favorited = dTweet.GetProp("favorited") as bool?;
                retweeted = dTweet.GetProp("retweeted") as bool?;
                possibly_sensitive = dTweet.GetProp("possibly_sensitive") as bool?;

                if (cleanString == true)
                    text = text.cleanString();
            }
        }
Example #8
0
 /// <summary>
 /// Filling all the information related with a user
 /// </summary>
 /// <param name="dUser">Dictionary containing all the information coming from Twitter</param>
 private void fillUser(Dictionary<String, object> dUser)
 {
     if (dUser.GetProp("id") != null || dUser.GetProp("screen_name") != null)
     {
         is_translator = dUser.GetProp("is_translator") as bool?;
         notifications = dUser.GetProp("notifications");
         profile_use_background_image = dUser.GetProp("profile_use_background_image") as bool?;
         profile_background_image_url_https = dUser.GetProp("profile_background_image_url_https") as string;
         time_zone = dUser.GetProp("time_zone") as string;
         profile_text_color = dUser.GetProp("profile_text_color") as string;
         profile_image_url_https = dUser.GetProp("profile_image_url_https") as string;
         following = dUser.GetProp("following") as object[];
         verified = dUser.GetProp("verified") as bool?;
         profile_background_image_url = dUser.GetProp("profile_background_image_url") as string;
         default_profile_image = dUser.GetProp("default_profile_image") as bool?;
         profile_link_color = dUser.GetProp("profile_link_color") as string;
         description = dUser.GetProp("description") as string;
         id_str = dUser.GetProp("id_str") as string;
         contributors_enabled = dUser.GetProp("contributors_enabled") as bool?;
         geo_enabled = dUser.GetProp("geo_enabled") as bool?;
         favourites_count = dUser.GetProp("favourites_count") as int?;
         followers_count = dUser.GetProp("followers_count") as int?;
         profile_image_url = dUser.GetProp("profile_image_url") as string;
         //follow_request_sent = dUser.GetProp("follow_request_sent") as ;
         created_at = DateTime.ParseExact(dUser.GetProp("created_at") as string,
             "ddd MMM dd HH:mm:ss zzzz yyyy", CultureInfo.InvariantCulture);
         profile_background_color = dUser.GetProp("profile_background_color") as string;
         profile_background_tile = dUser.GetProp("profile_background_tile") as bool?;
         friends_count = dUser.GetProp("friends_count") as int?;
         url = dUser.GetProp("url") as string;
         show_all_inline_media = dUser.GetProp("show_all_inline_media") as bool?;
         statuses_count = dUser.GetProp("statuses_count") as int?;
         profile_sidebar_fill_color = dUser.GetProp("profile_sidebar_fill_color") as string;
         user_protected = dUser.GetProp("protected") as bool?;
         screen_name = dUser.GetProp("screen_name") as string;
         listed_count = dUser.GetProp("listed_count") as int?;
         name = dUser.GetProp("name") as string;
         profile_sidebar_border_color = dUser.GetProp("profile_sidebar_border_color") as string;
         location = dUser.GetProp("location") as string;
         var salut = dUser.GetProp("id");
         id = Convert.ToInt64(dUser.GetProp("id")) as long?;
         default_profile = dUser.GetProp("default_profile") as bool?;
         lang = dUser.GetProp("lang") as string;
         utc_offset = dUser.GetProp("utc_offset") as int?;
     }
     else
         throw new InvalidOperationException("Cannot create 'User' if id does not exist");
 }