本文整理汇总了C#中JsonObject.GetLong方法的典型用法代码示例。如果您正苦于以下问题:C# JsonObject.GetLong方法的具体用法?C# JsonObject.GetLong怎么用?C# JsonObject.GetLong使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JsonObject
的用法示例。
在下文中一共展示了JsonObject.GetLong方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Parse
public static FacebookObject Parse(JsonObject obj) {
if (obj == null) return null;
return new FacebookObject {
Id = obj.GetLong("id"),
Name = obj.GetString("name")
};
}
示例2: Parse
public static FacebookMessageTag Parse(JsonObject obj) {
return new FacebookMessageTag {
Id = obj.GetLong("id"),
Name = obj.GetString("name"),
Type = obj.GetString("type"),
Offset = obj.GetInt("offset"),
Length = obj.GetInt("length")
};
}
示例3: Parse
public static FacebookEventSummary Parse(JsonObject obj) {
return new FacebookEventSummary {
Id = obj.GetLong("id"),
Name = obj.GetString("name"),
StartTime = obj.GetDateTime("start_time"),
EndTime = obj.HasValue("end_time") ? (DateTime?) obj.GetDateTime("end_time") : null,
TimeZone = obj.GetString("timezone"),
Location = obj.GetString("location")
};
}
示例4: Parse
/// <summary>
/// Parse the JSON object of an account.
/// </summary>
/// <param name="obj">The JSON object.</param>
/// <returns></returns>
public static FacebookAccount Parse(JsonObject obj) {
if (obj == null) return null;
return new FacebookAccount {
Id = obj.GetLong("id"),
Name = obj.GetString("name"),
Category = obj.GetString("category"),
AccessToken = obj.GetString("access_token"),
Permissions = obj.GetArray<string>("perms") ?? new string[0]
};
}
示例5: Parse
public static TwitterMentionEntity Parse(JsonObject mention) {
return new TwitterMentionEntity {
UserId = mention.GetLong("id"),
UserIdStr = mention.GetString("id_str"),
ScreenName = mention.GetString("screen_name"),
Name = mention.GetString("name"),
StartIndex = mention.GetArray("indices").GetInt(0),
EndIndex = mention.GetArray("indices").GetInt(1)
};
}
示例6: Parse
public static FacebookEvent Parse(JsonObject obj) {
return new FacebookEvent {
Id = obj.GetLong("id"),
Name = obj.GetString("name"),
Description = obj.GetString("description"),
StartTime = obj.GetDateTime("start_time"),
EndTime = obj.HasValue("end_time") ? (DateTime?) obj.GetDateTime("end_time") : null,
TimeZone = obj.GetString("timezone"),
IsDateOnly = obj.HasValue("is_date_only") && obj.GetBoolean("is_date_only"),
Location = obj.GetString("location"),
Privacy = obj.GetString("privacy"),
UpdatedTime = obj.GetDateTime("updated_time")
};
}
示例7: Parse
public static FacebookPhoto Parse(JsonObject obj) {
if (obj == null) return null;
return new FacebookPhoto {
Id = obj.GetLong("id"),
Name = obj.GetString("name"),
Width = obj.GetInt("width"),
Height = obj.GetInt("height"),
Picture = obj.GetString("picture"),
Source = obj.GetString("source"),
Created = obj.GetDateTime("created_time"),
Updated = obj.GetDateTime("updated_time"),
Images = FacebookImage.ParseMultiple(obj.GetArray("images"))
};
}
示例8: Parse
public static TwitterMediaEntity Parse(JsonObject entity) {
return new TwitterMediaEntity {
Id = entity.GetLong("id"),
IdStr = entity.GetString("id_str"),
StartIndex = entity.GetArray("indices").GetInt(0),
EndIndex = entity.GetArray("indices").GetInt(1),
MediaUrl = entity.GetString("media_url"),
MediaUrlHttps = entity.GetString("media_url_https"),
Url = entity.GetString("url"),
DisplayUrl = entity.GetString("display_url"),
ExpandedUrl = entity.GetString("expanded_url"),
Type = entity.GetString("type"),
//SourceStatusId = entity.source_status_id
};
}
示例9: Parse
public static FacebookMeResponse Parse(JsonObject obj) {
if (obj == null) return null;
if (obj.HasValue("error")) throw obj.GetObject("error", FacebookException.Parse);
return new FacebookMeResponse {
Id = obj.GetLong("id"),
Name = obj.GetString("name"),
FirstName = obj.GetString("first_name"),
LastName = obj.GetString("last_name"),
Link = obj.GetString("link"),
UserName = obj.GetString("username"),
Gender = obj.GetString("gender"),
TimeZone = obj.HasValue("timezone") ? (int?) obj.GetInt("timezone") : null,
Locale = obj.GetString("locale"),
IsVerified = obj.HasValue("verified") ? (bool?) obj.GetBoolean("verified") : null,
UpdatedTime = obj.GetDateTime("updated_time")
};
}
示例10: Parse
/// <summary>
/// Gets a user from the specified <var>JsonObject</var>.
/// </summary>
/// <param name="obj">The instance of <var>JsonObject</var> to parse.</param>
public static FacebookUser Parse(JsonObject obj) {
if (obj == null) return null;
return new FacebookUser {
Id = obj.GetLong("id"),
Name = obj.GetString("name"),
FirstName = obj.GetString("first_name"),
LastName = obj.GetString("last_name"),
Link = obj.GetString("link"),
Username = obj.GetString("username"),
Hometown = obj.GetObject("hometown", FacebookObject.Parse),
Location = obj.GetObject("location", FacebookObject.Parse),
Gender = obj.GetString("gender"),
Email = obj.GetString("email"),
Timezone = obj.GetInt("timezone"),
Locale = obj.GetString("locale"),
Languages = obj.GetArray("languages", FacebookObject.Parse) ?? new FacebookObject[0],
IsVerified = obj.GetBoolean("verified")
};
}
示例11: Parse
/// <summary>
/// Gets a media from the specified <var>JsonObject</var>.
/// </summary>
/// <param name="obj">The instance of <var>JsonObject</var> to parse.</param>
public static InstagramMedia Parse(JsonObject obj) {
if (obj == null) return null;
JsonObject comments = obj.GetObject("comments");
JsonObject likes = obj.GetObject("likes");
string type = obj.GetString("type");
InstagramMedia media = null;
if (type == "image") {
media = new InstagramImage();
} else if (type == "video") {
media = new InstagramVideo {
Videos = obj.GetObject("videos", InstagramVideoSummary.Parse)
};
}
if (media != null) {
media.JsonObject = obj;
media.Id = obj.GetString("id");
media.Type = type;
media.Tags = obj.GetArray("tags").Cast<string>();
media.Created = SocialUtils.GetDateTimeFromUnixTime(obj.GetLong("created_time"));
media.Link = obj.GetString("link");
media.Filter = obj.GetString("filter");
media.CommentCount = comments.GetInt("count");
media.Comments = comments.GetArray("data", InstagramComment.Parse);
media.LikeCount = likes.GetInt("count");
media.Images = obj.GetObject("images", InstagramImageSummary.Parse);
media.Caption = obj.GetObject("caption", InstagramComment.Parse);
media.User = obj.GetObject("user", InstagramUser.Parse);
media.Location = obj.GetObject("location", InstagramLocation.Parse);
}
return media;
}
示例12: Parse
/// <summary>
/// Gets a user from the specified <var>JsonObject</var>.
/// </summary>
/// <param name="obj">The instance of <var>JsonObject</var> to parse.</param>
public static TwitterUser Parse(JsonObject obj) {
// Error checking
if (obj == null) return null;
if (obj.HasValue("error")) throw TwitterException.Parse(obj.GetArray("error"));
TwitterUser user = new TwitterUser();
#region Basic properties
user.JsonObject = obj;
user.Id = obj.GetLong("id");
user.IdStr = obj.GetString("id_str");
user.Name = obj.GetString("name");
user.ScreenName = obj.GetString("screen_name");
user.Location = obj.GetString("location");
user.Url = obj.GetString("url");
user.Description = obj.GetString("description");
user.IsProtected = obj.GetBoolean("protected");
user.FollowersCount = obj.GetInt("followers_count");
user.FriendsCount = obj.GetInt("friends_count");
user.ListedCount = obj.GetInt("listed_count");
user.CreatedAt = TwitterUtils.ParseDateTime(obj.GetString("created_at"));
user.FavouritesCount = obj.GetInt("favourites_count");
if (obj.HasValue("utc_offset")) user.UtcOffset = obj.GetInt("utc_offset");
user.TimeZone = obj.GetString("time_zone");
user.IsGeoEnabled = obj.GetBoolean("geo_enabled");
user.IsVerified = obj.GetBoolean("verified");
user.StatusesCount = obj.GetInt("statuses_count");
user.Language = obj.GetString("lang");
user.ContributorsEnabled = obj.GetBoolean("contributors_enabled");
user.IsTranslator = obj.GetBoolean("is_translator");
user.IsFollowing = obj.HasValue("following") && obj.GetBoolean("following");
user.FollowRequestSent = obj.HasValue("follow_request_sent") && obj.GetBoolean("follow_request_sent");
user.Notifications = obj.HasValue("notifications") && obj.GetBoolean("notifications");
user.Status = obj.GetObject("status", TwitterStatusMessage.Parse);
#endregion
#region Profile properties
user.HasDefaultProfile = obj.GetBoolean("default_profile");
user.HasDefaultProfileImage = obj.GetBoolean("default_profile_image");
user.ProfileBackgroundColor = obj.GetString("profile_background_color");
user.ProfileBackgroundImageUrl = obj.GetString("profile_background_image_url");
user.ProfileBackgroundImageUrlHttps = obj.GetString("profile_background_image_url_https");
user.ProfileBackgroundTile = obj.GetBoolean("profile_background_tile");
user.ProfileBannerUrl = obj.GetString("profile_banner_url");
user.ProfileImageUrl = obj.GetString("profile_image_url");
user.ProfileImageUrlHttps = obj.GetString("profile_image_url_https");
user.ProfileLinkColor = obj.GetString("profile_link_color");
user.ProfileSidebarBorderColor = obj.GetString("profile_sidebar_border_color");
user.ProfileSidebarFillColor = obj.GetString("profile_sidebar_fill_color");
user.ProfileTextColor = obj.GetString("profile_text_color");
user.ProfileUseBackgroundImage = obj.GetBoolean("profile_use_background_image");
#endregion
return user;
}
示例13: Parse
/// <summary>
/// Gets a post from the specified <var>JsonObject</var>.
/// </summary>
/// <param name="obj">The instance of <var>JsonObject</var> to parse.</param>
public static FacebookPostSummary Parse(JsonObject obj) {
if (obj == null) return null;
return new FacebookPostSummary {
JsonObject = obj,
Id = obj.GetString("id"),
From = obj.GetObject("from", FacebookObject.Parse),
Application = obj.GetObject("application", FacebookObject.Parse),
Properties = obj.GetArray("properties", FacebookPostProperties.Parse) ?? new FacebookPostProperties[0],
Caption = obj.GetString("caption"),
Message = obj.GetString("message"),
Description = obj.GetString("description"),
Story = obj.GetString("story"),
Picture = obj.GetString("picture"),
Link = obj.GetString("link"),
Name = obj.GetString("name"),
Icon = obj.GetString("icon"),
Type = obj.GetString("type"),
StatusType = obj.GetString("status_type"),
ObjectId = obj.HasValue("object_id") ? (long?) obj.GetLong("object_id") : null,
CreatedTime = obj.GetDateTime("created_time"),
UpdatedTime = obj.GetDateTime("updated_time"),
Likes = obj.GetObject("likes", FacebookLikes.Parse),
Comments = obj.GetObject("comments", FacebookComments.Parse)
};
}
示例14: Parse
/// <summary>
/// Gets a status message (tweet) from the specified <var>JsonObject</var>.
/// </summary>
/// <param name="obj">The instance of <var>JsonObject</var> to parse.</param>
public static TwitterStatusMessage Parse(JsonObject obj) {
// Error checking
if (obj == null) return null;
if (obj.HasValue("error")) throw TwitterException.Parse(obj.GetArray("error"));
TwitterStatusMessage msg = new TwitterStatusMessage {
JsonObject = obj,
Id = obj.GetLong("id"),
IdStr = obj.GetString("id_str"),
Text = obj.GetString("text"),
Source = obj.GetString("source"),
IsTruncated = obj.GetBoolean("truncated")
};
// Twitter has some strange date formats
msg.CreatedAt = TwitterUtils.ParseDateTimeUtc(obj.GetString("created_at"));
// Parse the reply information
if (obj.HasValue("in_reply_to_status_id")) {
msg.InReplyTo = new TwitterReplyTo {
StatusId = obj.GetLong("in_reply_to_status_id"),
StatusIdStr = obj.GetString("in_reply_to_status_id_str"),
UserId = obj.GetLong("in_reply_to_user_id"),
UserIdStr = obj.GetString("in_reply_to_user_id_str"),
ScreenName = obj.GetString("in_reply_to_screen_name")
};
}
msg.Retweets = obj.GetInt("retweet_count");
// Related to the authenticating user
msg.Favorited = obj.GetBoolean("favorited");
msg.Retweeted = obj.GetBoolean("retweeted");
// Parse the entities (if any)
msg.Entities = TwitterStatusMessageEntities.Parse(obj.GetObject("entities"));
// For some weird reason Twitter flips the coordinates by writing longitude before latitude
// See: https://dev.twitter.com/docs/platform-objects/tweets#obj-coordinates)
msg.Coordinates = TwitterCoordinates.Parse(obj.GetObject("coordinates"));
// See: https://dev.twitter.com/docs/platform-objects/tweets#obj-contributors
/*if (tweet.contributors != null) {
List<TwitterContributor> contributors = new List<TwitterContributor>();
foreach (dynamic contributor in tweet.contributors) {
contributors.Add(new TwitterContributor {
UserId = contributor.id,
ScreenName = contributor.screen_name
});
}
msg.Contributors = contributors.ToArray();
}*/
msg.User = obj.GetObject("user", TwitterUser.Parse);
msg.Place = obj.GetObject("place", TwitterPlace.Parse);
return msg;
}
示例15: Parse
public static InstagramTag Parse(JsonObject obj) {
return new InstagramTag {
MediaCount = obj.GetLong("media_count"),
Name = obj.GetString("name")
};
}