Get rid of Newtonsoft.Json everywhere but the HTTP abstractions
This commit is contained in:
parent
7b06965f14
commit
cf0cd743b8
15 changed files with 105 additions and 48 deletions
|
@ -1,14 +1,26 @@
|
|||
using System;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Geekbot.Core.WikipediaClient.Page
|
||||
{
|
||||
public class PageApiUrls
|
||||
{
|
||||
[JsonPropertyName("summary")]
|
||||
public Uri Summary { get; set; }
|
||||
|
||||
[JsonPropertyName("metadata")]
|
||||
public Uri Metadata { get; set; }
|
||||
|
||||
[JsonPropertyName("references")]
|
||||
public Uri References { get; set; }
|
||||
|
||||
[JsonPropertyName("media")]
|
||||
public Uri Media { get; set; }
|
||||
|
||||
[JsonPropertyName("edit_html")]
|
||||
public Uri EditHtml { get; set; }
|
||||
|
||||
[JsonPropertyName("talk_page_html")]
|
||||
public Uri TalkPageHtml { get; set; }
|
||||
}
|
||||
}
|
|
@ -1,8 +1,13 @@
|
|||
namespace Geekbot.Core.WikipediaClient.Page
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Geekbot.Core.WikipediaClient.Page
|
||||
{
|
||||
public class PageContentUrlCollection
|
||||
{
|
||||
[JsonPropertyName("desktop")]
|
||||
public PageContentUrls Desktop { get; set; }
|
||||
|
||||
[JsonPropertyName("mobile")]
|
||||
public PageContentUrls Mobile { get; set; }
|
||||
}
|
||||
}
|
|
@ -1,12 +1,20 @@
|
|||
using System;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Geekbot.Core.WikipediaClient.Page
|
||||
{
|
||||
public class PageContentUrls
|
||||
{
|
||||
[JsonPropertyName("page")]
|
||||
public Uri Page { get; set; }
|
||||
|
||||
[JsonPropertyName("revisions")]
|
||||
public Uri Revisions { get; set; }
|
||||
|
||||
[JsonPropertyName("edit")]
|
||||
public Uri Edit { get; set; }
|
||||
|
||||
[JsonPropertyName("talk")]
|
||||
public Uri Talk { get; set; }
|
||||
}
|
||||
}
|
|
@ -1,8 +1,13 @@
|
|||
namespace Geekbot.Core.WikipediaClient.Page
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Geekbot.Core.WikipediaClient.Page
|
||||
{
|
||||
public class PageCoordinates
|
||||
{
|
||||
[JsonPropertyName("lat")]
|
||||
public float Lat { get; set; }
|
||||
|
||||
[JsonPropertyName("lon")]
|
||||
public float Lon { get; set; }
|
||||
}
|
||||
}
|
|
@ -1,11 +1,17 @@
|
|||
using System;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Geekbot.Core.WikipediaClient.Page
|
||||
{
|
||||
public class PageImage
|
||||
{
|
||||
[JsonPropertyName("source")]
|
||||
public Uri Source { get; set; }
|
||||
|
||||
[JsonPropertyName("width")]
|
||||
public int Width { get; set; }
|
||||
|
||||
[JsonPropertyName("height")]
|
||||
public int Height { get; set; }
|
||||
|
||||
}
|
||||
|
|
|
@ -1,8 +1,13 @@
|
|||
namespace Geekbot.Core.WikipediaClient.Page
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Geekbot.Core.WikipediaClient.Page
|
||||
{
|
||||
public class PageNamespace
|
||||
{
|
||||
[JsonPropertyName("id")]
|
||||
public ulong Id { get; set; }
|
||||
|
||||
[JsonPropertyName("text")]
|
||||
public string Text { get; set; }
|
||||
}
|
||||
}
|
|
@ -1,67 +1,65 @@
|
|||
using System;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Geekbot.Core.WikipediaClient.Page
|
||||
{
|
||||
public class PagePreview
|
||||
{
|
||||
[JsonProperty("type")]
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
[JsonPropertyName("type")]
|
||||
public PageTypes Type { get; set; }
|
||||
|
||||
[JsonProperty("title")]
|
||||
[JsonPropertyName("title")]
|
||||
public string Title { get; set; }
|
||||
|
||||
[JsonProperty("displaytitle")]
|
||||
[JsonPropertyName("displaytitle")]
|
||||
public string Displaytitle { get; set; }
|
||||
|
||||
[JsonProperty("namespace")]
|
||||
[JsonPropertyName("namespace")]
|
||||
public PageNamespace Namespace { get; set; }
|
||||
|
||||
[JsonProperty("titles")]
|
||||
[JsonPropertyName("titles")]
|
||||
public PageTitles Titles { get; set; }
|
||||
|
||||
[JsonProperty("pageid")]
|
||||
[JsonPropertyName("pageid")]
|
||||
public ulong Pageid { get; set; }
|
||||
|
||||
[JsonProperty("thumbnail")]
|
||||
[JsonPropertyName("thumbnail")]
|
||||
public PageImage Thumbnail { get; set; }
|
||||
|
||||
[JsonProperty("originalimage")]
|
||||
[JsonPropertyName("originalimage")]
|
||||
public PageImage Originalimage { get; set; }
|
||||
|
||||
[JsonProperty("lang")]
|
||||
[JsonPropertyName("lang")]
|
||||
public string Lang { get; set; }
|
||||
|
||||
[JsonProperty("dir")]
|
||||
[JsonPropertyName("dir")]
|
||||
public string Dir { get; set; }
|
||||
|
||||
[JsonProperty("revision")]
|
||||
public ulong Revision { get; set; }
|
||||
[JsonPropertyName("revision")]
|
||||
public string Revision { get; set; }
|
||||
|
||||
[JsonProperty("tid")]
|
||||
[JsonPropertyName("tid")]
|
||||
public string Tid { get; set; }
|
||||
|
||||
[JsonProperty("timestamp")]
|
||||
[JsonPropertyName("timestamp")]
|
||||
public DateTimeOffset Timestamp { get; set; }
|
||||
|
||||
[JsonProperty("description")]
|
||||
[JsonPropertyName("description")]
|
||||
public string Description { get; set; }
|
||||
|
||||
[JsonProperty("coordinates")]
|
||||
[JsonPropertyName("coordinates")]
|
||||
public PageCoordinates Coordinates { get; set; }
|
||||
|
||||
[JsonProperty("content_urls")]
|
||||
[JsonPropertyName("content_urls")]
|
||||
public PageContentUrlCollection ContentUrls { get; set; }
|
||||
|
||||
[JsonProperty("api_urls")]
|
||||
[JsonPropertyName("api_urls")]
|
||||
public PageApiUrls ApiUrls { get; set; }
|
||||
|
||||
[JsonProperty("extract")]
|
||||
[JsonPropertyName("extract")]
|
||||
public string Extract { get; set; }
|
||||
|
||||
[JsonProperty("extract_html")]
|
||||
[JsonPropertyName("extract_html")]
|
||||
public string ExtractHtml { get; set; }
|
||||
}
|
||||
}
|
|
@ -1,10 +1,16 @@
|
|||
namespace Geekbot.Core.WikipediaClient.Page
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Geekbot.Core.WikipediaClient.Page
|
||||
{
|
||||
public class PageTitles
|
||||
{
|
||||
[JsonPropertyName("Canonical")]
|
||||
public string Canonical { get; set; }
|
||||
public string Normalized { get; set; }
|
||||
public string Display { get; set; }
|
||||
|
||||
[JsonPropertyName("Normalized")]
|
||||
public string Normalized { get; set; }
|
||||
|
||||
[JsonPropertyName("Display")]
|
||||
public string Display { get; set; }
|
||||
}
|
||||
}
|
|
@ -1,7 +1,9 @@
|
|||
using System.Runtime.Serialization;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Geekbot.Core.WikipediaClient.Page
|
||||
{
|
||||
[JsonConverter(typeof(JsonStringEnumConverter))]
|
||||
public enum PageTypes
|
||||
{
|
||||
[EnumMember(Value = "standard")]
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
using System.Net.Http;
|
||||
using System.Text.Json;
|
||||
using System.Threading.Tasks;
|
||||
using Geekbot.Core.WikipediaClient.Page;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Geekbot.Core.WikipediaClient
|
||||
{
|
||||
|
@ -19,7 +19,7 @@ namespace Geekbot.Core.WikipediaClient
|
|||
response.EnsureSuccessStatusCode();
|
||||
|
||||
var stringResponse = await response.Content.ReadAsStringAsync();
|
||||
return JsonConvert.DeserializeObject<PagePreview>(stringResponse);
|
||||
return JsonSerializer.Deserialize<PagePreview>(stringResponse);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue