本文整理汇总了C#中VkNet.Utils.VkResponse.ContainsKey方法的典型用法代码示例。如果您正苦于以下问题:C# VkResponse.ContainsKey方法的具体用法?C# VkResponse.ContainsKey怎么用?C# VkResponse.ContainsKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VkNet.Utils.VkResponse
的用法示例。
在下文中一共展示了VkResponse.ContainsKey方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FromJson
internal static Relative FromJson(VkResponse response)
{
var relative = new Relative();
// Согласно документации VK API, должно возвращаться поле id, однако фактически может возвращаться uid (для старых версий API).
// Можно будет парсить только id после перевода всех методов на более новые версии (как минимум Users.Search).
if (response.ContainsKey("id"))
relative.Id = response["id"];
else if (response.ContainsKey("uid"))
relative.Id = response["uid"];
relative.Type = response["type"];
relative.Name = response["name"];
return relative;
}
示例2: FromJson
/// <summary>
/// Разобрать из json.
/// </summary>
/// <param name="response">Ответ сервера.</param>
/// <returns></returns>
public static AppGetObject FromJson(VkResponse response)
{
AppGetObject appGetObject;
if (response.ContainsKey("items"))
{
appGetObject = new AppGetObject
{
TotalCount = response["count"],
Apps = response["items"].ToVkCollectionOf<App>(r => r),
Friends = response["profiles"].ToVkCollectionOf<User>(r => r)
};
} else
{
appGetObject = new AppGetObject
{
TotalCount = response["count"],
Apps = response["items"].ToVkCollectionOf<App>(r => r)
};
}
return appGetObject;
}
示例3: FromJson
/// <summary>
/// Разобрать из json.
/// </summary>
/// <param name="response">Ответ сервера.</param>
/// <returns></returns>
/// <exception cref="System.Exception">"Типа '{0}' не существует. Пожалуйста заведите задачу на сайте проекта: https://github.com/vknet/vk/issues"</exception>
internal static UserOrGroup FromJson(VkResponse response)
{
var userOrGroup = new UserOrGroup
{
Users = new List<User>(),
Groups = new List<Group>()
};
if (response.ContainsKey("count"))
{
userOrGroup.TotalCount = response["count"];
}
VkResponseArray result = response;
foreach (var item in result)
{
switch (item["type"].ToString())
{
case "group":
{
Group @group = item;
userOrGroup.Groups.Add(@group);
}
break;
case "profile":
{
User user = item;
userOrGroup.Users.Add(user);
}
break;
default:
{
throw new System.Exception(string.Format("Типа '{0}' не существует. Пожалуйста заведите задачу на сайте проекта: https://github.com/vknet/vk/issues", item["type"]));
}
}
}
return userOrGroup;
}
示例4: FromJson
/// <summary>
/// Разобрать из json.
/// </summary>
/// <param name="response">Ответ сервера.</param>
/// <returns></returns>
internal static WallGetObject FromJson(VkResponse response)
{
WallGetObject wallGetObject;
if (response.ContainsKey("items"))
{
wallGetObject = new WallGetObject
{
TotalCount = response["count"],
WallPosts = response["items"].ToReadOnlyCollectionOf<Post>(r => r),
Profiles = response["profiles"].ToReadOnlyCollectionOf<User>(r => r),
Groups = response["groups"].ToReadOnlyCollectionOf<Group>(r => r)
};
}
else
{
wallGetObject = new WallGetObject
{
WallPosts = response.ToReadOnlyCollectionOf<Post>(r => r)
};
}
return wallGetObject;
}
示例5: FromJson
internal static Group FromJson(VkResponse response)
{
var group = new Group();
group.Id = response["id"] ?? response["gid"];
group.Name = response["name"];
group.ScreenName = response["screen_name"];
group.IsClosed = response["is_closed"];
group.IsAdmin = response["is_admin"];
group.AdminLevel = response["admin_level"];
group.IsMember = response["is_member"];
group.Type = response["type"];
group.PhotoPreviews = response;
// опциональные поля
group.CityId = response.ContainsKey("city") ? response["city"]["id"] : null;
group.CountryId = response.ContainsKey("country") ? response["country"]["id"] : null;
group.Place = response["place"];
group.Description = response["description"];
group.WikiPage = response["wiki_page"];
group.MembersCount = response["members_count"];
group.Counters = response["counters"];
group.StartDate = response["start_date"];
group.EndDate = response["finish_date"] ?? response["end_date"];
group.CanPost = response["can_post"];
group.CanSeelAllPosts = response["can_see_all_posts"];
group.CanUploadDocuments = response["can_upload_doc"];
group.CanCreateTopic = response["can_create_topic"];
group.Activity = response["activity"];
group.Status = response["status"];
group.Contacts = response["contacts"];
group.Links = response["links"];
group.FixedPostId = response["fixed_post"];
group.IsVerified = response["verified"];
group.Site = response["site"];
group.InvitedBy = response["invited_by"];
return group;
}
示例6: FromJson
internal static PhotoAlbum FromJson(VkResponse response)
{
var album = new PhotoAlbum();
if (response.ContainsKey("aid"))
album.Id = response["aid"];
else
album.Id = response["id"];
album.ThumbId = Utilities.GetNullableLongId(response["thumb_id"]);
album.OwnerId = Utilities.GetNullableLongId(response["owner_id"]);
album.Title = response["title"];
album.Description = response["description"];
album.Created = response["created"];
album.Updated = response["updated"];
album.Size = response["size"];
album.Privacy = Utilities.GetNullableLongId(response["privacy"]);
album.CommentPrivacy = Utilities.GetNullableLongId(response["comment_privacy"]);
album.CanUpload = response["can_upload"];
album.PrivacyView = response["privacy_view"];
album.ThumbSrc = response["thumb_src"];
return album;
}
示例7: FromJson
/// <summary>
/// Разобрать из json.
/// </summary>
/// <param name="response">Ответ сервера.</param>
/// <returns></returns>
public static PushSettings FromJson(VkResponse response)
{
var result = new PushSettings
{
Msg = response["msg"],
Chat = response["chat"],
Friend = response.ContainsKey("friend") && response["mutual"],
FriendFound = response["friend_found"],
FriendAccepted = response["friend_accepted"],
Reply = response["reply"],
Comment = response.ContainsKey("comment") && response["fr_of_fr"],
Mention = response.ContainsKey("mention") && response["fr_of_fr"],
Like = response.ContainsKey("like") && response["fr_of_fr"],
Repost = response.ContainsKey("repost") && response["fr_of_fr"],
WallPost = response["wall_post"],
WallPublish = response["wall_publish"],
GroupInvite = response["group_invite"],
GroupAccepted = response["group_accepted"],
EventSoon = response["event_soon"],
TagPhoto = response.ContainsKey("tag_photo") && response["fr_of_fr"],
AppRequest = response["app_request"],
SdkOpen = response["sdk_open"],
NewPost = response["new_post"],
Birthday = response["birthday"]
};
return result;
}