/// <summary>
 /// Create a Message and fill it with some information given in parameter (creation date, id, text)
 /// This information can be retrieved directly from the content without creating any new object
 /// </summary>
 /// <param name="messageContent">Values of the message's attributes</param>
 private void FillBasicMessageInfoFromDictionary(Dictionary <String, object> messageContent)
 {
     this.CreatedAt = DateTime.ParseExact(messageContent.GetProp("created_at") as string,
                                          "ddd MMM dd HH:mm:ss zzzz yyyy", CultureInfo.InvariantCulture);
     this.Id   = Convert.ToInt64(messageContent.GetProp("id") as long?);
     this.Text = messageContent.GetProp("text") as string;
 }
Beispiel #2
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>));
            }
        }
Beispiel #3
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>));
            }
        }
Beispiel #4
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);
            }
        }
Beispiel #5
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);
            }
        }
Beispiel #6
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);
            }
        }
Beispiel #7
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);
            }
        }
        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);
            }
        }
        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);
            }
        }
        /// <summary>
        /// Creates an Hashtag entity based on information retrieved from twitter
        /// </summary>
        /// <param name="hashTagEntity">Information retrieved from Twitter</param>
        public HashTagEntity(Dictionary <String, object> hashTagEntity)
        {
            Text    = hashTagEntity.GetProp("text") as string;
            Indices = new ObservableCollection <int>();

            var hashTagIndices = hashTagEntity.GetProp("indices") as object[];

            if (hashTagIndices != null)
            {
                foreach (int indice in hashTagIndices)
                {
                    Indices.Add(indice);
                }
            }
        }
Beispiel #11
0
        /// <summary>
        /// Creates a URL with information retrieved from Twitter
        /// </summary>
        /// <param name="urlEntity">Information retrieved from Twitter</param>
        public UrlEntity(Dictionary <String, object> urlEntity)
        {
            Url          = urlEntity.GetProp("url") as string;
            DisplayedUrl = urlEntity.GetProp("display_url") as string;
            ExpandedUrl  = urlEntity.GetProp("expanded_url") as string;
            Indices      = new ObservableCollection <int>();

            object[] indices = urlEntity.GetProp("indices") as object[];
            if (indices != null)
            {
                foreach (int indice in indices)
                {
                    Indices.Add(indice);
                }
            }
        }
Beispiel #12
0
        // TODO : Implement trend_location
        #endregion

        /// <summary>
        /// Create settings based on information retrieved from twitter
        /// </summary>
        /// <param name="settingsValues"></param>
        public TokenUserSettings(Dictionary <string, object> settingsValues)
        {
            // TODO : Implement time_zone here
            Protected                = settingsValues.GetProp("protected") as bool?;
            ScreenName               = settingsValues.GetProp("screen_name") as string;
            AlwaysUseHttps           = settingsValues.GetProp("always_use_https") as bool?;
            UseCookiePersonalization = settingsValues.GetProp("use_cookie_personalization") as bool?;
            // TODO : Implement sleep_time here
            GeoEnabled                = settingsValues.GetProp("geo_enabled") as bool?;
            Language                  = settingsValues.GetProp("language") as string;
            DiscoverableByEmail       = settingsValues.GetProp("discoverable_by_email") as bool?;
            DiscoverableByMobilePhone = settingsValues.GetProp("discoverable_by_mobile_phone") as bool?;
            DisplaySensitiveMedia     = settingsValues.GetProp("display_sensitive_media") as bool?;
            // TODO : Implement trend_location here
        }
Beispiel #13
0
        /// <summary>
        /// Creates a UserMentionEntity based on information retrieved from Twitter
        /// </summary>
        /// <param name="userMentionEntity">Information retrieved from Twitter</param>
        public UserMentionEntity(Dictionary <String, object> userMentionEntity)
        {
            Id         = userMentionEntity.GetProp("id") as long?;
            IdStr      = userMentionEntity.GetProp("id_str") as string;
            ScreenName = userMentionEntity.GetProp("screen_name") as string;
            Name       = userMentionEntity.GetProp("name") as string;

            Indices = new ObservableCollection <int>();

            var mentionIndices = userMentionEntity.GetProp("indices") as object[];

            if (mentionIndices != null)
            {
                foreach (int indice in mentionIndices)
                {
                    Indices.Add(indice);
                }
            }
        }
Beispiel #14
0
        /// <summary>
        /// Populate a mention from information retrieved
        /// </summary>
        /// <param name="dTweet">Object containing Mention information</param>
        /// <param name="cleanString">Does the string needs to be cleanup when retrieved</param>
        protected override void Populate(Dictionary <String, object> dTweet, bool cleanString = true)
        {
            // initialize all the fields associated to the Tweet class
            base.Populate(dTweet, cleanString);

            if (Id != null)
            {
                // If Tweet initialization worked, initialize the fields associated to the Mention class
                _annotations = dTweet.GetProp("annotations") as string;
            }
        }
Beispiel #15
0
        /// <summary>
        /// Creates a media object based on information retrieved from Twitter
        /// </summary>
        /// <param name="mediaEntity">Information retrieved from Twitter</param>
        public MediaEntity(Dictionary <String, object> mediaEntity)
        {
            Id            = mediaEntity.GetProp("id") as long?;
            IdStr         = mediaEntity.GetProp("id_str") as string;
            MediaURL      = mediaEntity.GetProp("media_url") as string;
            MediaURLHttps = mediaEntity.GetProp("media_url_https") as string;

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

            var indicesInfo = mediaEntity.GetProp("indices") as object[];

            if (indicesInfo != null)
            {
                foreach (int indice in indicesInfo)
                {
                    indices.Add(indice);
                }
            }

            URLProperties = new UrlEntity()
            {
                Url          = mediaEntity.GetProp("url") as string,
                DisplayedUrl = mediaEntity.GetProp("display_url") as string,
                ExpandedUrl  = mediaEntity.GetProp("expanded_url") as string,
                Indices      = indices
            };

            MediaType = mediaEntity.GetProp("type") as string;

            Sizes = new Dictionary <string, IMediaEntitySize>();
            Dictionary <String, object> tmpSizes = mediaEntity.GetProp("sizes") as Dictionary <String, object>;

            if (tmpSizes != null)
            {
                foreach (object size in tmpSizes)
                {
                    KeyValuePair <String, object> pair = (KeyValuePair <String, object>)size;
                    Sizes.Add(pair.Key, new MediaEntitySize(pair.Value as Dictionary <String, object>));
                }
            }
        }
        /// <summary>
        /// Create a Message and fill all its fields.
        /// Do nothing if the parameter is null.
        /// </summary>
        /// <param name="messageContent">Values of the message's attributes</param>
        public override void Populate(Dictionary <String, object> messageContent)
        {
            // cannot set the message fields if the content is not available
            if (messageContent == null)
            {
                return;
            }

            // set the basic fields of the message
            FillBasicMessageInfoFromDictionary(messageContent);

            if (messageContent.GetProp("sender") is Dictionary <String, object> )
            {
                this.Sender = User.Create(messageContent.GetProp("sender"));
            }

            if (messageContent.GetProp("recipient") is Dictionary <String, object> )
            {
                this.Receiver = User.Create(messageContent.GetProp("recipient"));
            }

            _messageCreatedFromApi = false;
        }
Beispiel #17
0
 /// <summary>
 /// Create a user from information retrieved from Twitter
 /// </summary>
 /// <param name="tweetObject">Information retrieved from Twitter</param>
 /// <param name="token">Token saved in class propreties</param>
 /// <param name="shareTokenWithChild">Shall the token be shared to objects created from the user</param>
 public Tweet(Dictionary <string, object> tweetObject,
              IToken token             = null,
              bool shareTokenWithChild = true)
     : this(shareTokenWithChild)
 {
     if (tweetObject.GetProp("id") != null)
     {
         Populate(tweetObject);
         _token = token;
     }
     else
     {
         throw new InvalidOperationException("Cannot create 'Tweet' if id does not exist");
     }
 }
Beispiel #18
0
 private Tweet(dynamic dynamicTweet)
     : this()
 {
     if (dynamicTweet is Dictionary <String, object> )
     {
         Dictionary <String, object> dTweet = dynamicTweet as Dictionary <String, object>;
         if (dTweet.GetProp("id") != null)
         {
             fillTweet(dTweet);
         }
         else
         {
             throw new InvalidOperationException("Cannot create 'Tweet' if id does not exist");
         }
     }
 }
Beispiel #19
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;
        }
Beispiel #20
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;
        }
Beispiel #21
0
        /// <summary>
        /// Creates a store of entities based on information retrieved from Twitter
        /// </summary>
        /// <param name="entities">Twitter information</param>
        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>) as IUrlEntity)
                   .ToList() : null;

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

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

            Hashtags = entities.GetProp("hashtags") != null ?
                       (from x in (entities.GetProp("hashtags") as object[])
                        select new HashTagEntity(x as Dictionary <String, object>) as IHashTagEntity)
                       .ToList() : null;
        }
Beispiel #22
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");
 }
Beispiel #23
0
        /// <summary>
        /// Pupulating all the information related with a user
        /// </summary>
        /// <param name="dUser">Dictionary containing all the information coming from Twitter</param>
        public override void Populate(Dictionary <String, object> dUser)
        {
            if (dUser == null)
            {
                throw new ArgumentException("dynamicUser cannot be null");
            }

            if (dUser.GetProp("id") != null || dUser.GetProp("screen_name") != null)
            {
                IsTranslator                   = dUser.GetProp("is_translator") as bool?;
                Notifications                  = dUser.GetProp("notifications");
                ProfileUseBackgroundImage      = dUser.GetProp("profile_use_background_image") as bool?;
                ProfileBackgroundImageURLHttps = dUser.GetProp("profile_background_image_url_https") as string;
                TimeZone                  = dUser.GetProp("time_zone") as string;
                ProfileTextColor          = dUser.GetProp("profile_text_color") as string;
                ProfileImageURLHttps      = dUser.GetProp("profile_image_url_https") as string;
                Following                 = dUser.GetProp("following") as object[];
                Verified                  = dUser.GetProp("verified") as bool?;
                ProfileBackgroundImageURL = dUser.GetProp("profile_background_image_url") as string;
                DefaultProfileImage       = dUser.GetProp("default_profile_image") as bool?;
                ProfileLinkColor          = dUser.GetProp("profile_link_color") as string;
                Description               = dUser.GetProp("description") as string;
                IdStr = dUser.GetProp("id_str") as string;
                ContributorsEnabled = dUser.GetProp("contributors_enabled") as bool?;
                GeoEnabled          = dUser.GetProp("geo_enabled") as bool?;
                FavouritesCount     = dUser.GetProp("favourites_count") as int?;
                FollowersCount      = dUser.GetProp("followers_count") as int?;
                ProfileImageURL     = dUser.GetProp("profile_image_url") as string;
                //follow_request_sent = dUser.GetProp("follow_request_sent") as ;

                string createdAt = dUser.GetProp("created_at") as string;

                if (createdAt != null)
                {
                    CreatedAt = DateTime.ParseExact(dUser.GetProp("created_at") as string,
                                                    "ddd MMM dd HH:mm:ss zzzz yyyy", CultureInfo.InvariantCulture);
                }

                ProfileBackgroundColor = dUser.GetProp("profile_background_color") as string;
                ProfileBackgroundTile  = dUser.GetProp("profile_background_tile") as bool?;
                FriendsCount           = dUser.GetProp("friends_count") as int?;
                URL = dUser.GetProp("url") as string;
                ShowAllInlineMedia      = dUser.GetProp("show_all_inline_media") as bool?;
                StatusesCount           = dUser.GetProp("statuses_count") as int?;
                ProfileSidebarFillColor = dUser.GetProp("profile_sidebar_fill_color") as string;
                UserProtected           = dUser.GetProp("protected") as bool?;
                ScreenName  = dUser.GetProp("screen_name") as string;
                ListedCount = dUser.GetProp("listed_count") as int?;
                Name        = dUser.GetProp("name") as string;
                ProfileSidebarBorderColor = dUser.GetProp("profile_sidebar_border_color") as string;
                Location       = dUser.GetProp("location") as string;
                Id             = Convert.ToInt64(dUser.GetProp("id"));
                DefaultProfile = dUser.GetProp("default_profile") as bool?;
                Lang           = dUser.GetProp("lang") as string;
                UTCOffset      = dUser.GetProp("utc_offset") as int?;
            }
            else
            {
                throw new InvalidOperationException("Cannot create 'User' if id does not exist");
            }
        }
Beispiel #24
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();
                }
            }
        }
Beispiel #25
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();
            }
        }
Beispiel #26
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?;
 }
Beispiel #27
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");
     }
 }
Beispiel #28
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?;
 }
Beispiel #29
0
        /// <summary>
        /// Populate a tweet from information retrieved from twitter
        /// </summary>
        /// <param name="dTweet">Object containing Tweet information</param>
        /// <param name="cleanString">Does the string needs to be cleanup when retrieved</param>
        protected virtual void Populate(Dictionary <String, object> dTweet, bool cleanString)
        {
            if (dTweet.GetProp("id") != null)
            {
                CreatedAt = DateTime.ParseExact(dTweet.GetProp("created_at") as string,
                                                "ddd MMM dd HH:mm:ss zzzz yyyy", CultureInfo.InvariantCulture);
                Id                   = Convert.ToInt64(dTweet.GetProp("id_str"));
                IdValue              = Convert.ToInt64(dTweet.GetProp("id"));
                IdStr                = dTweet.GetProp("id_str") as string;
                Text                 = dTweet.GetProp("text") as string;
                Source               = dTweet.GetProp("source ") as string;
                Truncated            = dTweet.GetProp("truncated") as bool?;
                InReplyToStatusId    = dTweet.GetProp("in_reply_to_status_id") as int?;
                InReplyToStatusIdStr = dTweet.GetProp("in_reply_to_status_id_str") as string;
                InReplyToUserId      = dTweet.GetProp("in_reply_to_user_id") as int?;
                InReplyToUserIdStr   = dTweet.GetProp("in_reply_to_user_id_str") as string;
                InReplyToScreenName  = dTweet.GetProp("in_reply_to_screen_name") as string;
                Creator              = User.Create(dTweet.GetProp("user"));

                if (_shareTokenWithChild)
                {
                    Creator.ObjectToken = _token;
                }

                Location = Geo.Create(dTweet.GetProp("geo"));

                if (Location != null)
                {
                    LocationCoordinates = Location.GeoCoordinates;
                }

                // Create Place
                _place = dTweet.GetProp("place") as string;

                // Create Contributors
                var contributors = dTweet.GetProp("contributors");

                RetweetCount = dTweet.GetProp("retweet_count") as int?;

                if (dTweet.ContainsKey("entities"))
                {
                    Entities = new TweetEntities(dTweet["entities"] as Dictionary <String, object>);
                }

                Favourited        = dTweet.GetProp("favorited") as bool?;
                Retweeted         = dTweet.GetProp("retweeted") as bool?;
                PossiblySensitive = dTweet.GetProp("possibly_sensitive") as bool?;

                if (dTweet.ContainsKey("retweeted_status"))
                {
                    var retweet = dTweet.GetProp("retweeted_status") as Dictionary <string, object>;

                    if (retweet != null)
                    {
                        Retweeting = new Tweet(retweet);
                    }
                }

                if (cleanString)
                {
                    Text = Text.CleanString();
                }

                _isTweetPublished = true;
            }
        }
Beispiel #30
0
 /// <summary>
 /// Creates a media size from information retrived from Twitter
 /// </summary>
 /// <param name="mediaEntitySize">Information retrieved from Twitter</param>
 public MediaEntitySize(Dictionary <string, object> mediaEntitySize)
 {
     Width  = mediaEntitySize.GetProp("w") as int?;
     Resize = mediaEntitySize.GetProp("resize") as string;
     Height = mediaEntitySize.GetProp("h") as int?;
 }