Skip to content

Commit 22aa4cd

Browse files
authored
Merge pull request #21 from FrApp42/dev/main
XML deserialization support & CI fixes
2 parents fbf7e7d + 2f77cac commit 22aa4cd

File tree

6 files changed

+26
-18
lines changed

6 files changed

+26
-18
lines changed

.github/workflows/build.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88

99
jobs:
1010
build:
11-
runs-on: ubuntu-latest
11+
runs-on: windows-latest
1212

1313
steps:
1414
- uses: actions/checkout@v4

Docs/docs/Awake.md

+1-10
Original file line numberDiff line numberDiff line change
@@ -62,18 +62,9 @@ Awake.CompleteExit(0, false, "AppName");
6262
Updated version of Power Awake
6363

6464
```C#
65-
using FrApps42.System.Computer.Awake.v1;
65+
using FrApps42.System.Computer.Awake.v2;
6666
...
6767

68-
private static void LogUnexpectedOrCancelledKeepAwakeThreadCompletion(){
69-
Console.WriteLine("The keep-awake thread was terminated early.");
70-
}
71-
72-
private static void LogCompletedKeepAwakeThread(bool result)
73-
{
74-
Console.WriteLine($"Exited keep-awake thread successfully: {result}");
75-
}
76-
7768
// Keep Screen on
7869
Awake..SetIndefiniteKeepAwake(true);
7970
// Keep Screen off

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ This repos contains tool classes in C# for multiple types of usage.
1313
* WakeOnLan: Power on a device with it mac address.
1414

1515
* `FrApp42.Web` - [Link](https://www.nuget.org/packages/FrApp42.Web)
16-
* Request: Make API request for any of your C# projects. ⚠️ *SOAP requests are not supported.* ⚠️
16+
* Request: Make API request for any of your C# projects.
1717

1818
## Authors
1919
* [AnthoDingo](https://github.com)

System/System.csproj

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<Title>FrApp42 System</Title>
1010
<Authors>FrenchyApps42, Sikelio, AnthoDingo</Authors>
1111
<Copyright>GPLv3</Copyright>
12-
<PackageProjectUrl>https://github.com/FrApp42/Tools</PackageProjectUrl>
12+
<PackageProjectUrl>https://frapp42.github.io/Tools/api.System/FrApp42.System.Computer.Awake.v1.html</PackageProjectUrl>
1313
<RepositoryUrl>https://github.com/FrApp42/Tools.git</RepositoryUrl>
1414
<RepositoryType>git</RepositoryType>
1515
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
@@ -22,7 +22,7 @@
2222
<PackageIcon>logo.png</PackageIcon>
2323
<Version>1.1.0</Version>
2424
<AssemblyVersion>1.1.0</AssemblyVersion>
25-
<PackageReleaseNotes>Implement Awake from Microsoft Powertoys</PackageReleaseNotes>
25+
<PackageReleaseNotes>Fix Awake v1 &amp; v2</PackageReleaseNotes>
2626
<FileVersion>1.1.0</FileVersion>
2727
</PropertyGroup>
2828

Web/API/Request.cs

+19-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using Newtonsoft.Json;
33
using System.Net.Http.Headers;
44
using System.Text;
5+
using System.Xml.Serialization;
56

67
namespace FrApp42.Web.API
78
{
@@ -392,8 +393,24 @@ private async Task<Result<T>> Process<T>(HttpRequestMessage request)
392393

393394
if (response.IsSuccessStatusCode)
394395
{
395-
Stream ContentResponse = await response.Content?.ReadAsStreamAsync();
396-
result.Value = await System.Text.Json.JsonSerializer.DeserializeAsync<T>(ContentResponse);
396+
string MediaType = response.Content?.Headers?.ContentType?.MediaType.ToLower();
397+
string ContentResponse = await response.Content?.ReadAsStringAsync();
398+
399+
switch (true)
400+
{
401+
case bool b when (MediaType.Contains("application/xml")):
402+
XmlSerializer xmlSerializer = new(typeof(T));
403+
StringReader reader = new(ContentResponse);
404+
405+
result.Value = (T)xmlSerializer.Deserialize(reader);
406+
break;
407+
case bool b when (MediaType.Contains("application/json")):
408+
result.Value = JsonConvert.DeserializeObject<T>(ContentResponse);
409+
break;
410+
default:
411+
result.Value = default;
412+
break;
413+
}
397414
}
398415
else
399416
{

Web/Web.csproj

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<Title>FrApp42 Web</Title>
1010
<Authors>FrenchyApps42, Sikelio, AnthoDingo</Authors>
1111
<Copyright>GPLv3</Copyright>
12-
<PackageProjectUrl>https://github.com/FrApp42/Tools</PackageProjectUrl>
12+
<PackageProjectUrl>https://frapp42.github.io/Tools/api.Web/FrApp42.Web.API.html</PackageProjectUrl>
1313
<RepositoryUrl>https://github.com/FrApp42/Tools.git</RepositoryUrl>
1414
<RepositoryType>git</RepositoryType>
1515
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
@@ -20,7 +20,7 @@
2020
<PackageReadmeFile>README.md</PackageReadmeFile>
2121
<Company>FrenchyApps42</Company>
2222
<PackageIcon>logo.png</PackageIcon>
23-
<Version>1.1.0</Version>
23+
<Version>1.2.0</Version>
2424
</PropertyGroup>
2525

2626
<ItemGroup>

0 commit comments

Comments
 (0)