Add .NET standard and .NET framework targets. v2.0

Use nuget System.Text.Json and System.Net.Http deps, switch "Protocol" to "Scheme", and bump version to 2.0
This commit is contained in:
Ian Webster 2020-12-24 11:14:08 -05:00
parent 6969c66df7
commit 2a93ad3680
2 changed files with 21 additions and 17 deletions

View file

@ -1,6 +1,4 @@
using System;
using System.Collections.Specialized;
using System.Web;
using System.Net.Http;
using System.Text;
using System.Text.Json;
@ -25,7 +23,7 @@ namespace QuickChart
public string Key { get; set; }
public string Config { get; set; }
public string Protocol { get; set; }
public string Scheme { get; set; }
public string Host { get; set; }
public int Port { get; set; }
@ -38,7 +36,7 @@ namespace QuickChart
DevicePixelRatio = 1.0;
BackgroundColor = "transparent";
Protocol = "https";
Scheme = "https";
Host = "quickchart.io";
Port = 443;
}
@ -50,18 +48,19 @@ namespace QuickChart
throw new NullReferenceException("You must set Config on the QuickChart object before generating a URL");
}
NameValueCollection queryString = HttpUtility.ParseQueryString(string.Empty);
queryString.Add("w", Width.ToString());
queryString.Add("h", Height.ToString());
queryString.Add("devicePixelRatio", DevicePixelRatio.ToString());
queryString.Add("bkg", BackgroundColor);
queryString.Add("c", Config);
StringBuilder builder = new StringBuilder();
builder.Append("w=").Append(Width.ToString());
builder.Append("&h=").Append(Height.ToString());
builder.Append("&devicePixelRatio=").Append(DevicePixelRatio.ToString());
builder.Append("&bkg=").Append(Uri.EscapeDataString(BackgroundColor));
builder.Append("&c=").Append(Uri.EscapeDataString(Config));
if (!string.IsNullOrEmpty(Key))
{
queryString.Add("key", Key);
builder.Append("&key=").Append(Uri.EscapeDataString(Key));
}
return $"{Protocol}://{Host}:{Port}/chart?{queryString}";
return $"{Scheme}://{Host}:{Port}/chart?{builder}";
}
public string GetShortUrl()
@ -84,7 +83,7 @@ namespace QuickChart
key = Key,
}, options);
string url = $"{Protocol}://{Host}:{Port}/chart/create";
string url = $"{Scheme}://{Host}:{Port}/chart/create";
HttpResponseMessage response = Client.PostAsync(
url,
@ -121,7 +120,7 @@ namespace QuickChart
key = Key,
}, options);
string url = $"{Protocol}://{Host}:{Port}/chart";
string url = $"{Scheme}://{Host}:{Port}/chart";
HttpResponseMessage response = Client.PostAsync(
url,

View file

@ -2,19 +2,24 @@
<PropertyGroup>
<OutputType>Library</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFrameworks>netcoreapp3.1;netstandard2.0;net472</TargetFrameworks>
<PackOnBuild>true</PackOnBuild>
<Authors>Ian Webster</Authors>
<Copyright>Ian Webster 2020</Copyright>
<PackageLicenseUrl>https://github.com/typpo/quickchart-csharp/blob/main/LICENSE</PackageLicenseUrl>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<Owners>QuickChart</Owners>
<PackageProjectUrl>https://github.com/typpo/quickchart-csharp</PackageProjectUrl>
<Summary>Client library for the QuickChart Chart API, used to generate chart images.</Summary>
<PackageTags>chart image, chart api, chart, charts</PackageTags>
<PackageTags>chart image, chart api, chart, charts, image charts</PackageTags>
<Title>QuickChart</Title>
<Description>Client library for the QuickChart Chart API, used to generate chart images.</Description>
<PackageVersion>1.0.0</PackageVersion>
<PackageVersion>2.0.0</PackageVersion>
<PackageId>QuickChart</PackageId>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="System.Text.Json" Version="5.0.0" />
<PackageReference Include="System.Net.Http" Version="4.3.4" />
</ItemGroup>
</Project>