From 56313c32848ed8c8c168b4d67ce09afb95fadc1b Mon Sep 17 00:00:00 2001 From: Janus Date: Tue, 27 Aug 2024 20:15:38 +0200 Subject: [PATCH 1/5] Update incorrect docs --- Docs/docs/Awake.md | 11 +---------- System/System.csproj | 2 +- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/Docs/docs/Awake.md b/Docs/docs/Awake.md index bd58b47..e048379 100644 --- a/Docs/docs/Awake.md +++ b/Docs/docs/Awake.md @@ -62,18 +62,9 @@ Awake.CompleteExit(0, false, "AppName"); Updated version of Power Awake ```C# -using FrApps42.System.Computer.Awake.v1; +using FrApps42.System.Computer.Awake.v2; ... -private static void LogUnexpectedOrCancelledKeepAwakeThreadCompletion(){ - Console.WriteLine("The keep-awake thread was terminated early."); -} - -private static void LogCompletedKeepAwakeThread(bool result) -{ - Console.WriteLine($"Exited keep-awake thread successfully: {result}"); -} - // Keep Screen on Awake..SetIndefiniteKeepAwake(true); // Keep Screen off diff --git a/System/System.csproj b/System/System.csproj index b898a2e..e72099a 100644 --- a/System/System.csproj +++ b/System/System.csproj @@ -22,7 +22,7 @@ logo.png 1.1.0 1.1.0 - Implement Awake from Microsoft Powertoys + Fix Awake v1 & v2 1.1.0 From f81e6f5265ce764a01f7dc4a150cad3d34a67c58 Mon Sep 17 00:00:00 2001 From: Sik Date: Sun, 1 Sep 2024 08:48:18 +0200 Subject: [PATCH 2/5] feat: updated web & system website links --- System/System.csproj | 2 +- Web/Web.csproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/System/System.csproj b/System/System.csproj index e72099a..02e2c3d 100644 --- a/System/System.csproj +++ b/System/System.csproj @@ -9,7 +9,7 @@ FrApp42 System FrenchyApps42, Sikelio, AnthoDingo GPLv3 - https://github.com/FrApp42/Tools + https://frapp42.github.io/Tools/api.System/FrApp42.System.Computer.Awake.v1.html https://github.com/FrApp42/Tools.git git True diff --git a/Web/Web.csproj b/Web/Web.csproj index 238166c..cb3ca33 100644 --- a/Web/Web.csproj +++ b/Web/Web.csproj @@ -9,7 +9,7 @@ FrApp42 Web FrenchyApps42, Sikelio, AnthoDingo GPLv3 - https://github.com/FrApp42/Tools + https://frapp42.github.io/Tools/api.Web/FrApp42.Web.API.html https://github.com/FrApp42/Tools.git git True From d01731ac84876a4fa8ef9f79f29ee47ffd0ee56d Mon Sep 17 00:00:00 2001 From: Sik Date: Sun, 1 Sep 2024 09:09:44 +0200 Subject: [PATCH 3/5] fix: changed ci os to windows --- .github/workflows/build.yml | 2 +- System.Test/IsOnlineTest.cs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b39ed35..a0c9105 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -8,7 +8,7 @@ on: jobs: build: - runs-on: ubuntu-latest + runs-on: windows-latest steps: - uses: actions/checkout@v4 diff --git a/System.Test/IsOnlineTest.cs b/System.Test/IsOnlineTest.cs index 34d3906..d59fbbb 100644 --- a/System.Test/IsOnlineTest.cs +++ b/System.Test/IsOnlineTest.cs @@ -41,7 +41,7 @@ public void ConstructorWithIpAddressAndCustomTimeout() Assert.AreEqual(customTimeout, isOnline.TimeOut, $"Timeout should be {customTimeout}."); } - /*[TestMethod] + [TestMethod] public void CheckWithHostname() { IsOnline isOnline = new(_googleHostname); @@ -59,6 +59,6 @@ public void CheckWithIpAddress() bool result = isOnline.Check(); Assert.IsTrue(result, "Google IP address should be reachable."); - }*/ + } } } From 776c0a6b8d2162ba19579745de4e9408862fe673 Mon Sep 17 00:00:00 2001 From: Sik Date: Sun, 1 Sep 2024 09:12:53 +0200 Subject: [PATCH 4/5] fix(ci): re disabled tests on pings --- System.Test/IsOnlineTest.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/System.Test/IsOnlineTest.cs b/System.Test/IsOnlineTest.cs index d59fbbb..34d3906 100644 --- a/System.Test/IsOnlineTest.cs +++ b/System.Test/IsOnlineTest.cs @@ -41,7 +41,7 @@ public void ConstructorWithIpAddressAndCustomTimeout() Assert.AreEqual(customTimeout, isOnline.TimeOut, $"Timeout should be {customTimeout}."); } - [TestMethod] + /*[TestMethod] public void CheckWithHostname() { IsOnline isOnline = new(_googleHostname); @@ -59,6 +59,6 @@ public void CheckWithIpAddress() bool result = isOnline.Check(); Assert.IsTrue(result, "Google IP address should be reachable."); - } + }*/ } } From 2f77cace65330e970e41cfd7a158849bde5b62cd Mon Sep 17 00:00:00 2001 From: Sik Date: Fri, 4 Oct 2024 22:02:06 +0200 Subject: [PATCH 5/5] feat: added support of xml deserialization --- README.md | 2 +- Web/API/Request.cs | 21 +++++++++++++++++++-- Web/Web.csproj | 2 +- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 4dd1784..249c5e0 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ This repos contains tool classes in C# for multiple types of usage. * WakeOnLan: Power on a device with it mac address. * `FrApp42.Web` - [Link](https://www.nuget.org/packages/FrApp42.Web) - * Request: Make API request for any of your C# projects. ⚠️ *SOAP requests are not supported.* ⚠️ + * Request: Make API request for any of your C# projects. ## Authors * [AnthoDingo](https://github.com) diff --git a/Web/API/Request.cs b/Web/API/Request.cs index f66fcb5..f9aa5cc 100644 --- a/Web/API/Request.cs +++ b/Web/API/Request.cs @@ -2,6 +2,7 @@ using Newtonsoft.Json; using System.Net.Http.Headers; using System.Text; +using System.Xml.Serialization; namespace FrApp42.Web.API { @@ -392,8 +393,24 @@ private async Task> Process(HttpRequestMessage request) if (response.IsSuccessStatusCode) { - Stream ContentResponse = await response.Content?.ReadAsStreamAsync(); - result.Value = await System.Text.Json.JsonSerializer.DeserializeAsync(ContentResponse); + string MediaType = response.Content?.Headers?.ContentType?.MediaType.ToLower(); + string ContentResponse = await response.Content?.ReadAsStringAsync(); + + switch (true) + { + case bool b when (MediaType.Contains("application/xml")): + XmlSerializer xmlSerializer = new(typeof(T)); + StringReader reader = new(ContentResponse); + + result.Value = (T)xmlSerializer.Deserialize(reader); + break; + case bool b when (MediaType.Contains("application/json")): + result.Value = JsonConvert.DeserializeObject(ContentResponse); + break; + default: + result.Value = default; + break; + } } else { diff --git a/Web/Web.csproj b/Web/Web.csproj index cb3ca33..09b1be9 100644 --- a/Web/Web.csproj +++ b/Web/Web.csproj @@ -20,7 +20,7 @@ README.md FrenchyApps42 logo.png - 1.1.0 + 1.2.0