Пример #1
0
        public RelatedResults(JsonData resultsJson)
        {
            if (resultsJson == null) return;

            ResultAnnotations = new Annotation(resultsJson.GetValue<JsonData>("annotations"));
            Score = resultsJson.GetValue<double>("score");
            Kind = resultsJson.GetValue<string>("kind");
            JsonData value = resultsJson.GetValue<JsonData>("value");
            ValueAnnotations = new Annotation(value.GetValue<JsonData>("annotations"));
            Retweeted = value.GetValue<bool>("retweeted");
            InReplyToScreenName = value.GetValue<string>("in_reply_to_screen_name");
            var contributors = value.GetValue<JsonData>("contributors");
            Contributors =
                contributors == null ?
                    new List<Contributor>() :
                    (from JsonData contributor in contributors
                     select new Contributor(contributor))
                    .ToList();
            Coordinates = new Coordinate(value.GetValue<JsonData>("coordinates"));
            Place = new Place(value.GetValue<JsonData>("place"));
            User = new User(value.GetValue<JsonData>("user"));
            RetweetCount = value.GetValue<int>("retweet_count");
            IDString = value.GetValue<string>("id_str");
            InReplyToUserID = value.GetValue<ulong>("in_reply_to_user_id");
            Favorited = value.GetValue<bool>("favorited");
            InReplyToStatusIDString = value.GetValue<string>("in_reply_to_status_id_str");
            InReplyToStatusID = value.GetValue<ulong>("in_reply_to_status_id");
            Source = value.GetValue<string>("source");
            CreatedAt = value.GetValue<string>("created_at").GetDate(DateTime.MaxValue);
            InReplyToUserIDString = value.GetValue<string>("in_reply_to_user_id_str");
            Truncated = value.GetValue<bool>("truncated");
            Geo = new Geo(value.GetValue<JsonData>("geo"));
            Text = value.GetValue<string>("text");
        }
Пример #2
0
        public Friendship(JsonData friendJson)
        {
            if (friendJson == null) return;

            TargetRelationship = new Relationship(friendJson.GetValue<JsonData>("target"));
            SourceRelationship = new Relationship(friendJson.GetValue<JsonData>("source"));
        }
Пример #3
0
        public Media(JsonData media)
        {
            if (media == null) return;

            Image = new MediaImage(media.GetValue<JsonData>("image"));
            MediaID = media.GetValue<string>("media_id_string").GetULong(0);
            Size = media.GetValue<int>("size");
        }
Пример #4
0
 public SavedSearch(JsonData searchJson)
 {
     Query = searchJson.GetValue<string>("query");
     Name = searchJson.GetValue<string>("name");
     Postition = searchJson.GetValue<int>("position");
     IDString = searchJson.GetValue<string>("id_str");
     CreatedAt = searchJson.GetValue<string>("created_at").GetDate(DateTime.MaxValue);
 }
Пример #5
0
 public Event(JsonData evt)
 {
     Target = new User(evt.GetValue<JsonData>("target"));
     Source = new User(evt.GetValue<JsonData>("source"));
     EventName = evt.GetValue<string>("event");
     var targetObj = evt.GetValue<JsonData>("target_object", defaultValue: null);
     TargetObject = targetObj == null ? (string)null : targetObj.ToString();
     CreatedAt = evt.GetValue<string>("created_at").GetDate(DateTime.MaxValue);
 }
Пример #6
0
 public ForUser(JsonData user)
 {
     UserID = user.GetValue<ulong>("for_user");
     var message = user.GetValue<JsonData>("message");
     var friends = message.GetValue<JsonData>("friends");
     Friends =
         friends == null ? new List<ulong>() :
         (from JsonData friend in friends
          select (ulong)friend)
         .ToList();
 }
Пример #7
0
        public VideoInfo(JsonData videoInfo)
        {
            AspectRatio = new AspectRatio(videoInfo.GetValue<JsonData>("aspect_ratio"));
            Duration = videoInfo.GetValue<int>("duration_millis");
            JsonData variants = videoInfo.GetValue<JsonData>("variants");

            if (variants != null && variants.Count > 0)
                Variants =
                    (from JsonData variant in videoInfo.GetValue<JsonData>("variants")
                     select new Variant(variant))
                    .ToList();
        }
Пример #8
0
        public Category(JsonData catJson)
        {
            Size = catJson.GetValue<int>("size");
            Name = catJson.GetValue<string>("name");
            Slug = catJson.GetValue<string>("slug");

            var users = catJson.GetValue<JsonData>("users");
            if (users != null)
                Users =
                    (from JsonData user in users
                     select new User(user))
                    .ToList();
        }
Пример #9
0
        internal Geometry(JsonData geometry)
        {
            if (geometry == null) return;

            Type = geometry.GetValue<string>("type");

            var coordinates = geometry.GetValue<JsonData>("coordinates");
            Coordinates =
                (from JsonData outer in coordinates
                 from JsonData coord in outer
                 select new Coordinate(coord))
                .ToList();
        }
Пример #10
0
 public Disconnect(JsonData json)
 {
     var disconnect = json.GetValue<JsonData>("disconnect");
     Code = disconnect.GetValue<int>("code");
     StreamName = disconnect.GetValue<string>("stream_name");
     Reason = disconnect.GetValue<string>("reason");
 }
Пример #11
0
 public TooManyFollows(JsonData warning)
 {
     var warn = warning.GetValue<JsonData>("warning");
     Code = warn.GetValue<string>("code");
     Message = warn.GetValue<string>("message");
     UserID = warn.GetValue<ulong>("user_id");
 }
Пример #12
0
 public Stall(JsonData stall)
 {
     var warning = stall.GetValue<JsonData>("user_withheld");
     Code = warning.GetValue<string>("code");
     Message = warning.GetValue<string>("message");
     PercentFull = warning.GetValue<int>("percent_full");
 }
Пример #13
0
 public Delete(JsonData delete)
 {
     var del = delete.GetValue<JsonData>("delete");
     var status = del.GetValue<JsonData>("status");
     StatusID = status.GetValue<ulong>("id");
     UserID = status.GetValue<ulong>("user_id");
 }
Пример #14
0
 public FriendsList(JsonData friends)
 {
     Friends =
         friends == null ? new List<ulong>() :
         (from JsonData friend in friends.GetValue<JsonData>("friends")
          select (ulong)friend)
         .ToList();
 }
Пример #15
0
 public ControlStreamFollow(JsonData csJson)
 {
     var follow = csJson.GetValue<JsonData>("follow");
     User = new ControlStreamUser(follow.GetValue<JsonData>("user"));
     Friends =
         (from JsonData friend in follow.GetValue<JsonData>("friends")
          select (ulong)friend)
         .ToList();
     Cursors = new Cursors(follow);
 }
Пример #16
0
        public IDList(JsonData idJson)
        {
            if (idJson == null) return;

            CursorMovement = new Cursors(idJson);
            var ids = idJson.GetValue<JsonData>("ids");
            IDs =
                (from JsonData id in ids
                 select (ulong)id)
                .ToList();
        }
Пример #17
0
 public UserWithheld(JsonData user)
 {
     var withheld = user.GetValue<JsonData>("user_withheld");
     UserID = withheld.GetValue<ulong>("user_id");
     var withheldCountries = withheld.GetValue<JsonData>("withheld_in_countries");
     WithheldInCountries =
         withheldCountries == null ? new List<string>() :
         (from JsonData country in withheld.GetValue<JsonData>("withheld_in_countries")
          select country.ToString())
         .ToList();
 }
Пример #18
0
 public SearchMetaData(JsonData metaData)
 {
     CompletedIn = metaData.GetValue<decimal>("completed_in");
     MaxID = metaData.GetValue<string>("max_id_str").GetULong(0ul);
     NextResults = metaData.GetValue<string>("next_results");
     Query = metaData.GetValue<string>("query");
     RefreshUrl = metaData.GetValue<string>("refresh_url");
     Count = metaData.GetValue<int>("count");
     SinceID = metaData.GetValue<string>("since_id_str").GetULong(0ul);
 }
Пример #19
0
 public StatusWithheld(JsonData status)
 {
     var withheld = status.GetValue<JsonData>("status_withheld");
     StatusID = withheld.GetValue<ulong>("id");
     UserID = withheld.GetValue<ulong>("user_id");
     var withheldCountries = withheld.GetValue<JsonData>("withheld_in_countries");
     WithheldInCountries =
         withheldCountries == null ? new List<string>() :
         (from JsonData country in withheld.GetValue<JsonData>("withheld_in_countries")
          select country.ToString())
         .ToList();
 }
Пример #20
0
 public ControlStreamInfo(JsonData infoJson)
 {
     var info = infoJson.GetValue<JsonData>("info");
     Users =
         (from JsonData user in info.GetValue<JsonData>("users")
          select new ControlStreamUser(user))
         .ToList();
     Delimited = info.GetValue<string>("delimited");
     IncludeFollowingsActivity = info.GetValue<bool>("include_followings_activity");
     IncludeUserChanges = info.GetValue<bool>("include_user_changes");
     Replies = info.GetValue<string>("replies");
     With = info.GetValue<string>("with");
 }
Пример #21
0
        internal Location(JsonData trendLocation)
        {
            var placeType = trendLocation.GetValue<JsonData>("placeType");

            Country = trendLocation.GetValue<string>("country");
            Name = trendLocation.GetValue<string>("name");
            CountryCode = trendLocation.GetValue<string>("countryCode");
            ParentID = trendLocation.GetValue<int>("parentid").ToString(CultureInfo.InvariantCulture);
            PlaceTypeName = placeType.GetValue<string>("name");
            PlaceTypeNameCode = placeType.GetValue<int>("code");
            Url = trendLocation.GetValue<string>("url");
            WoeID = trendLocation.GetValue<int>("woeid");
        }
Пример #22
0
        public Geo(JsonData geo)
        {
            if (geo == null) return;

            JsonData result = geo.GetValue<JsonData>("result");
            JsonData places = result.GetValue<JsonData>("places");

            Token = result.GetValue<string>("token");

            if (places != null)
            {
                Places =
                    (from JsonData place in places
                        select new Place(place))
                    .ToList();
            }
        }
Пример #23
0
        public Entities(JsonData entityJson)
        {
            if (entityJson == null) return;

            var hashTagEntities = entityJson.GetValue<JsonData>("hashtags");
            var mediaEntities = entityJson.GetValue<JsonData>("media");
            var urlEntities = entityJson.GetValue<JsonData>("urls");
            var userEntities = entityJson.GetValue<JsonData>("user_mentions");
            HashTagMentions =
                hashTagEntities == null
                    ? new List<HashTagMention>()
                    : (from JsonData hash in hashTagEntities
                       let indices = hash.GetValue<JsonData>("indices")
                       select new HashTagMention
                       {
                           Tag = hash.GetValue<string>("text"),
                           Start = indices.Count > 0 ? (int)indices[0] : 0,
                           End = indices.Count > 1 ? (int)indices[1] : 0
                       })
                       .ToList();
            MediaMentions =
                mediaEntities == null
                    ? new List<MediaMention>()
                    : (from JsonData media in mediaEntities
                       let indices = media.GetValue<JsonData>("indices")
                       let sizes = media.GetValue<JsonData>("sizes")
                       select new MediaMention
                       {
                           DisplayUrl = media.GetValue<string>("display_url"),
                           ExpandedUrl = media.GetValue<string>("expanded_url"),
                           ID = media.GetValue<ulong>("id"),
                           MediaUrl = media.GetValue<string>("media_url"),
                           MediaUrlHttps = media.GetValue<string>("media_url_https"),
                           Sizes =
                               (from key in (sizes as IDictionary<string, JsonData>).Keys as List<string>
                                let sizesKey = sizes.GetValue<JsonData>(key)
                                select new PhotoSize
                                {
                                    Type = key,
                                    Width = sizesKey.GetValue<int>("w"),
                                    Height = sizesKey.GetValue<int>("h"),
                                    Resize = sizesKey.GetValue<string>("resize")
                                })
                               .ToList(),
                           Type = media.GetValue<string>("type"),
                           Url = media.GetValue<string>("url"),
                           Start = indices.Count > 0 ? (int)indices[0] : 0,
                           End = indices.Count > 1 ? (int)indices[1] : 0
                       })
                       .ToList();
            UrlMentions =
                urlEntities == null
                    ? new List<UrlMention>()
                    : (from JsonData url in urlEntities
                       let indices = url.GetValue<JsonData>("indices")
                       select new UrlMention
                       {
                           Url = url.GetValue<string>("url"),
                           DisplayUrl = url.GetValue<string>("display_url"),
                           ExpandedUrl = url.GetValue<string>("expanded_url"),
                           Start = indices.Count > 0 ? (int)indices[0] : 0,
                           End = indices.Count > 1 ? (int)indices[1] : 0
                       })
                      .ToList();
            UserMentions =
                userEntities == null
                    ? new List<UserMention>()
                    : (from JsonData user in userEntities
                       let indices = user.GetValue<JsonData>("indices")
                       select new UserMention
                       {
                           ScreenName = user.GetValue<string>("screen_name"),
                           Name = user.GetValue<string>("name"),
                           Id = user.GetValue<ulong>("id"),
                           Start = indices.Count > 0 ? (int)indices[0] : 0,
                           End = indices.Count > 1 ? (int)indices[1] : 0
                       })
                      .ToList();
        }
Пример #24
0
 public Limit(JsonData json)
 {
     var scrub = json.GetValue<JsonData>("limit");
     Track = scrub.GetValue<ulong>("track");
 }
Пример #25
0
        public Relationship(JsonData relJson)
        {
            if (relJson == null) return;

            ScreenName = relJson.GetValue<string>("screen_name");
            Name = relJson.GetValue<string>("name");
            RetweetsWanted = relJson.GetValue<bool>("want_retweets");
            AllReplies = relJson.GetValue<bool>("all_replies");
            MarkedSpam = relJson.GetValue<bool>("marked_spam");
            FollowedBy = relJson.GetValue<bool>("followed_by");
            ID = relJson.GetValue<string>("id_str");
            Blocking = relJson.GetValue<bool>("blocking");
            NotificationsEnabled = relJson.GetValue<bool>("notifications_enabled");
            Following = relJson.GetValue<bool>("following");
            CanDm = relJson.GetValue<bool>("can_dm");
            var connections = relJson.GetValue<JsonData>("connections");
            if (connections != null)
            {
                Connections =
                    (from JsonData connection in connections
                        select connection.ToString())
                    .ToList(); 
            }
        }
Пример #26
0
 public EmbeddedStatus(JsonData embeddedStatusJson)
 {
     Html = embeddedStatusJson.GetValue<string>("html");
     AuthorName = embeddedStatusJson.GetValue<string>("author_name");
     AuthorUrl = embeddedStatusJson.GetValue<string>("author_url");
     ProviderName = embeddedStatusJson.GetValue<string>("provider_name");
     ProviderUrl = embeddedStatusJson.GetValue<string>("provider_url");
     Url = embeddedStatusJson.GetValue<string>("url");
     Version = embeddedStatusJson.GetValue<string>("version");
     Type = embeddedStatusJson.GetValue<string>("type");
     Height = embeddedStatusJson.GetValue<int>("height");
     Width = embeddedStatusJson.GetValue<int>("width");
     CacheAge = embeddedStatusJson.GetValue<string>("cache_age");
 }
Пример #27
0
 internal Cursors(JsonData cursors)
 {
     Next = cursors.GetValue<ulong>("next_cursor").ToString();
     Previous = cursors.GetValue<ulong>("previous_cursor").ToString();
 }
Пример #28
0
        internal Place(JsonData place)
        {
            if (place == null) return;

            ID = place.GetValue<string>("id");
            Name = place.GetValue<string>("name");
            Country = place.GetValue<string>("country");
            CountryCode = place.GetValue<string>("country_code");
            FullName = place.GetValue<string>("full_name");
            PlaceType = place.GetValue<string>("place_type");
            Url = place.GetValue<string>("url");
            BoundingBox = new Geometry(place.GetValue<JsonData>("bounding_box"));
            Geometry = new Geometry(place.GetValue<JsonData>("geometry"));

            var containedWithin = place.GetValue<JsonData>("contained_within");
            ContainedWithin = 
                containedWithin != null && containedWithin.Count > 0 ? 
                    new Place(containedWithin[0]) :
                    null;

            var polyLines = place.GetValue<JsonData>("polylines");
            PolyLines = 
                polyLines == null ? 
                    new List<string>() 
                        : 
                    (from JsonData line in polyLines
                     select line.ToString())
                    .ToList();

            var attrDict = place.GetValue<JsonData>("attributes") as IDictionary<string, JsonData>;
            Attributes =
                attrDict == null ?
                    new Dictionary<string, string>() 
                        :
                    (from string key in attrDict.Keys
                     select new 
                     { 
                         Key = key, 
                         Val = attrDict[key].ToString()
                     })
                    .ToDictionary(
                        attr => attr.Key,
                        attr => attr.Val);
        }
Пример #29
0
 internal Cursors(JsonData cursors)
 {
     Next = cursors.GetValue<string>("next_cursor_str");
     Previous = cursors.GetValue<string>("previous_cursor_str");
 }
Пример #30
0
        public User(JsonData user)
        {
            if (user == null) return;

            var userID = user.GetValue<int>("id").ToString(CultureInfo.InvariantCulture);
            Identifier = new UserIdentifier
            {
                ID = userID,
                UserID = userID,
                ScreenName = user.GetValue<string>("screen_name")
            };
            Name = user.GetValue<string>("name");
            Location = user.GetValue<string>("location");
            Description = user.GetValue<string>("description");
            ProfileImageUrl = user.GetValue<string>("profile_image_url");
            ProfileImageUrlHttps = user.GetValue<string>("profile_image_url_https");
            Url = user.GetValue<string>("url");
            Protected = user.GetValue<bool>("protected");
            ProfileUseBackgroundImage = user.GetValue<bool>("profile_use_background_image");
            IsTranslator = user.GetValue<bool>("is_translator");
            FollowersCount = user.GetValue<int>("followers_count");
            DefaultProfile = user.GetValue<bool>("default_profile");
            ProfileBackgroundColor = user.GetValue<string>("profile_background_color");
            LangResponse = user.GetValue<string>("lang");
            ProfileTextColor = user.GetValue<string>("profile_text_color");
            ProfileLinkColor = user.GetValue<string>("profile_link_color");
            ProfileSidebarFillColor = user.GetValue<string>("profile_sidebar_fill_color");
            ProfileSidebarBorderColor = user.GetValue<string>("profile_sidebar_border_color");
            FriendsCount = user.GetValue<int>("friends_count");
            DefaultProfileImage = user.GetValue<bool>("default_profile_image");
            CreatedAt = user.GetValue<string>("created_at").GetDate(DateTime.MinValue);
            FavoritesCount = user.GetValue<int>("favourites_count");
            UtcOffset = user.GetValue<int>("utc_offset");
            TimeZone = user.GetValue<string>("time_zone");
            ProfileBackgroundImageUrl = user.GetValue<string>("profile_background_image_url");
            ProfileBackgroundImageUrlHttps = user.GetValue<string>("profile_background_image_url_https");
            ProfileBackgroundTile = user.GetValue<bool>("profile_background_tile");
            ProfileBannerUrl = user.GetValue<string>("profile_banner_url");
            StatusesCount = user.GetValue<int>("statuses_count");
            Notifications = user.GetValue<bool>("notifications");
            GeoEnabled = user.GetValue<bool>("geo_enabled");
            Verified = user.GetValue<bool>("verified");
            ContributorsEnabled = user.GetValue<bool>("contributors_enabled");
            Following = user.GetValue<bool>("following");
            ShowAllInlineMedia = user.GetValue<bool>("show_all_inline_media");
            ListedCount = user.GetValue<int>("listed_count");
            FollowRequestSent = user.GetValue<bool>("follow_request_sent");
            Status = new Status(user.GetValue<JsonData>("status"));
            CursorMovement = new Cursors(user);
        }