From 2ce9e2c77ed98516fc65e11c114340e2431c37ed Mon Sep 17 00:00:00 2001 From: Oleksii Holub Date: Fri, 22 Dec 2017 16:29:50 +0200 Subject: [PATCH] Code styling --- DiscordChatExporter/Services/DataService.cs | 46 ++++++++++----------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/DiscordChatExporter/Services/DataService.cs b/DiscordChatExporter/Services/DataService.cs index 2597fe7..cabc2dc 100644 --- a/DiscordChatExporter/Services/DataService.cs +++ b/DiscordChatExporter/Services/DataService.cs @@ -21,27 +21,27 @@ namespace DiscordChatExporter.Services private User ParseUser(JToken token) { - var id = token.Value("id"); - var discriminator = token.Value("discriminator"); - var name = token.Value("username"); - var avatarHash = token.Value("avatar"); + var id = token["id"].Value(); + var discriminator = token["discriminator"].Value(); + var name = token["username"].Value(); + var avatarHash = token["avatar"].Value(); return new User(id, discriminator, name, avatarHash); } private Role ParseRole(JToken token) { - var id = token.Value("id"); - var name = token.Value("name"); + var id = token["id"].Value(); + var name = token["name"].Value(); return new Role(id, name); } private Guild ParseGuild(JToken token) { - var id = token.Value("id"); - var name = token.Value("name"); - var iconHash = token.Value("icon"); + var id = token["id"].Value(); + var name = token["name"].Value(); + var iconHash = token["icon"].Value(); var roles = token["roles"].Select(ParseRole).ToArray(); return new Guild(id, name, iconHash, roles); @@ -50,9 +50,9 @@ namespace DiscordChatExporter.Services private Channel ParseChannel(JToken token) { // Get basic data - var id = token.Value("id"); - var type = (ChannelType) token.Value("type"); - var topic = token.Value("topic"); + var id = token["id"].Value(); + var type = (ChannelType) token["type"].Value(); + var topic = token["topic"].Value(); // Extract name based on type string name; @@ -63,7 +63,7 @@ namespace DiscordChatExporter.Services } else { - name = token.Value("name"); + name = token["name"].Value(); } return new Channel(id, name, topic, type); @@ -72,11 +72,11 @@ namespace DiscordChatExporter.Services private Message ParseMessage(JToken token) { // Get basic data - var id = token.Value("id"); - var timeStamp = token.Value("timestamp"); - var editedTimeStamp = token.Value("edited_timestamp"); - var content = token.Value("content"); - var type = (MessageType) token.Value("type"); + var id = token["id"].Value(); + var timeStamp = token["timestamp"].Value(); + var editedTimeStamp = token["edited_timestamp"].Value(); + var content = token["content"].Value(); + var type = (MessageType) token["type"].Value(); // Workarounds for non-default types if (type == MessageType.RecipientAdd) @@ -101,13 +101,13 @@ namespace DiscordChatExporter.Services var attachments = new List(); foreach (var attachmentJson in token["attachments"].EmptyIfNull()) { - var attachmentId = attachmentJson.Value("id"); - var attachmentUrl = attachmentJson.Value("url"); + var attachmentId = attachmentJson["id"].Value(); + var attachmentUrl = attachmentJson["url"].Value(); var attachmentType = attachmentJson["width"] != null ? AttachmentType.Image : AttachmentType.Other; - var attachmentFileName = attachmentJson.Value("filename"); - var attachmentFileSize = attachmentJson.Value("size"); + var attachmentFileName = attachmentJson["filename"].Value(); + var attachmentFileSize = attachmentJson["size"].Value(); var attachment = new Attachment( attachmentId, attachmentType, attachmentUrl, @@ -195,7 +195,7 @@ namespace DiscordChatExporter.Services var content = await GetStringAsync(url); // Parse IDs - var guildIds = JArray.Parse(content).Select(t => t.Value("id")); + var guildIds = JArray.Parse(content).Select(t => t["id"].Value()); // Get full guild infos var guilds = new List();