feat: update to net7

This commit is contained in:
Mira 2023-09-21 17:13:21 +02:00
parent 3cab23c592
commit bae09d2727
Signed by untrusted user who does not match committer: Xorog
GPG key ID: 983798ED9C3E7C36
2 changed files with 151 additions and 151 deletions

View file

@ -3,19 +3,20 @@ using System.Net.Http;
using System.Text;
using System.Text.Json;
using System.IO;
using System.Text.Json.Serialization;
namespace QuickChart
namespace QuickChart;
internal class QuickChartShortUrlResponse
{
internal class QuickChartShortUrlResponse
{
#pragma warning disable IDE1006 // Naming Styles
public bool status { get; set; }
public string url { get; set; }
#pragma warning restore IDE1006 // Naming Styles
}
}
public class Chart
{
public class Chart
{
public int Width { get; set; }
public int Height { get; set; }
public double DevicePixelRatio { get; set; }
@ -29,7 +30,7 @@ namespace QuickChart
public string Host { get; set; }
public int Port { get; set; }
private static readonly HttpClient Client = new HttpClient();
private static readonly HttpClient Client = new();
public Chart(string scheme = null, string host = null, int? port = null)
{
@ -69,10 +70,10 @@ namespace QuickChart
}
var builder = new StringBuilder();
_ = builder.Append("w=").Append(this.Width.ToString());
_ = builder.Append("&h=").Append(this.Height.ToString());
_ = builder.Append("w=").Append(this.Width);
_ = builder.Append("&h=").Append(this.Height);
_ = builder.Append("&devicePixelRatio=").Append(this.DevicePixelRatio.ToString());
_ = builder.Append("&devicePixelRatio=").Append(this.DevicePixelRatio);
_ = builder.Append("&f=").Append(this.Format);
_ = builder.Append("&bkg=").Append(Uri.EscapeDataString(this.BackgroundColor));
_ = builder.Append("&c=").Append(Uri.EscapeDataString(this.Config));
@ -97,7 +98,7 @@ namespace QuickChart
var options = new JsonSerializerOptions
{
IgnoreNullValues = true
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull
};
var json = JsonSerializer.Serialize(new
@ -138,7 +139,7 @@ namespace QuickChart
var options = new JsonSerializerOptions
{
IgnoreNullValues = true
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull
};
var json = JsonSerializer.Serialize(new
@ -167,13 +168,12 @@ namespace QuickChart
public void ToFile(string filePath)
=> File.WriteAllBytes(filePath, this.ToByteArray());
}
}
public class ApiException : Exception
{
public class ApiException : Exception
{
public ApiException(string message, HttpResponseMessage response) : base(message)
=> this.Response = response;
public HttpResponseMessage Response { get; private set; }
}
}

View file

@ -2,7 +2,7 @@
<PropertyGroup>
<OutputType>Library</OutputType>
<TargetFrameworks>netcoreapp3.1;netstandard2.0;net472</TargetFrameworks>
<TargetFrameworks>net7.0</TargetFrameworks>
<PackOnBuild>true</PackOnBuild>
<Authors>Ian Webster</Authors>
<Copyright>Ian Webster</Copyright>