diff --git a/.idea/.idea.CShocker/.idea/riderPublish.xml b/.idea/.idea.CShocker/.idea/riderPublish.xml
new file mode 100644
index 0000000..934a055
--- /dev/null
+++ b/.idea/.idea.CShocker/.idea/riderPublish.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/CShocker/CShocker.csproj b/CShocker/CShocker.csproj
index 75df0e4..a5cce84 100644
--- a/CShocker/CShocker.csproj
+++ b/CShocker/CShocker.csproj
@@ -6,7 +6,7 @@
Glax
https://github.com/C9Glax/CShocker
git
- 3.0.0
+ 3.0.1
net8.0;net9.0
latestmajor
https://github.com/C9Glax/CShocker
diff --git a/CShocker/Devices/Additional/ApiHttpClient.cs b/CShocker/Devices/Additional/ApiHttpClient.cs
index 2808b44..30288cd 100644
--- a/CShocker/Devices/Additional/ApiHttpClient.cs
+++ b/CShocker/Devices/Additional/ApiHttpClient.cs
@@ -8,16 +8,30 @@ namespace CShocker.Devices.Additional;
public static class ApiHttpClient
{
- internal static HttpResponseMessage MakeAPICall(HttpMethod method, string uri, string? jsonContent, ILogger? logger = null, params ValueTuple[] customHeaders)
+ private static readonly ProductInfoHeaderValue UserAgent = GetUserAgent();
+
+ private static ProductInfoHeaderValue GetUserAgent()
{
Assembly assembly = Assembly.GetExecutingAssembly();
+ if (assembly.Location == String.Empty)
+ {
+ DirectoryInfo dir = new (AppContext.BaseDirectory);
+ FileInfo? f = dir.GetFiles("*.exe").FirstOrDefault();
+ if (f is null)
+ return new("CShocker", "Release");
+ assembly = Assembly.LoadFrom(f.FullName);
+ }
FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(assembly.Location);
- ProductInfoHeaderValue userAgent = new (fvi.ProductName ?? fvi.FileName, fvi.ProductVersion);
+ return new (fvi.ProductName ?? fvi.FileName, fvi.ProductVersion);
+ }
+
+ internal static HttpResponseMessage MakeAPICall(HttpMethod method, string uri, string? jsonContent, ILogger? logger = null, params ValueTuple[] customHeaders)
+ {
HttpRequestMessage request = new (method, uri)
{
Headers =
{
- UserAgent = { userAgent },
+ UserAgent = { UserAgent },
Accept = { new MediaTypeWithQualityHeaderValue("application/json") },
}