From 8d38e883df86b5b4f15e612fcf7bcc2310d040ae Mon Sep 17 00:00:00 2001 From: Developer 02 Date: Wed, 26 Jun 2024 16:40:54 +0200 Subject: [PATCH] =?UTF-8?q?Die=20Klasse=20Method=20(Http)=20und=20unn?= =?UTF-8?q?=C3=B6tige=20Erweiterungen=20wurden=20entfernt.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DigitalData.Core.Client/HttpExtensions.cs | 49 ----------------------- DigitalData.Core.Client/Method.cs | 7 ---- 2 files changed, 56 deletions(-) delete mode 100644 DigitalData.Core.Client/Method.cs diff --git a/DigitalData.Core.Client/HttpExtensions.cs b/DigitalData.Core.Client/HttpExtensions.cs index 2501fa3..79910d3 100644 --- a/DigitalData.Core.Client/HttpExtensions.cs +++ b/DigitalData.Core.Client/HttpExtensions.cs @@ -8,22 +8,6 @@ namespace DigitalData.Core.Client /// public static class HttpExtensions { - /// - /// Fetches data from the specified URL using the given HTTP method. - /// - /// The URL to fetch data from. - /// The HTTP method to use for the request. Defaults to GET. - /// A task representing the HTTP response message. - public static async Task Fetch(this string url, Method method = Method.GET) - { - using HttpClient client = new(); - return method switch - { - Method.GET => await client.GetAsync(url), - _ => throw new NotImplementedException(nameof(method)), - }; - } - /// /// Reads the content of the HTTP response message as a string. /// @@ -61,39 +45,6 @@ namespace DigitalData.Core.Client return JsonConvert.DeserializeObject(json) ?? string.Empty; } - /// - /// Fetches data from the specified URL using the given HTTP method and reads the response content as a string. - /// - /// The URL to fetch data from. - /// The HTTP method to use for the request. Defaults to GET. - /// A task representing the response content as a string. - public static async Task FetchText(this string url, Method method = Method.GET) => await url.Fetch(method: method).ThenAsync(Text); - - /// - /// Fetches data from the specified URL using the given HTTP method and deserializes the response content to a specified type. - /// - /// The type to deserialize the response content to. - /// The URL to fetch data from. - /// The HTTP method to use for the request. Defaults to GET. - /// A task representing the deserialized response content. - public static async Task FetchJson(this string url, Method method = Method.GET) => await url.Fetch(method: method).ThenAsync(Json); - - /// - /// Fetches data from the specified URL using the given HTTP method and deserializes the response content to a dynamic object. - /// - /// The URL to fetch data from. - /// The HTTP method to use for the request. Defaults to GET. - /// A task representing the deserialized response content as a dynamic object. - public static async Task FetchJson(this string url, Method method = Method.GET) => await url.Fetch(method: method).ThenAsync(Json); - - /// - /// Fetches data from the specified URL using the given HTTP method and deserializes the response content to a list of dynamic objects. - /// - /// The URL to fetch data from. - /// The HTTP method to use for the request. Defaults to GET. - /// A task representing the deserialized response content as a list of dynamic objects. - public static async Task> FetchJsonList(this string url, Method method = Method.GET) => await url.Fetch(method: method).ThenAsync(JsonList); - /// /// Executes an action when a task is completed. /// diff --git a/DigitalData.Core.Client/Method.cs b/DigitalData.Core.Client/Method.cs deleted file mode 100644 index a4ab8c4..0000000 --- a/DigitalData.Core.Client/Method.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace DigitalData.Core.Client -{ - public enum Method - { - GET - } -} \ No newline at end of file