Add support to dotnet standard and framework

This commit is contained in:
2025-12-22 09:51:08 -03:00
parent e3c42a9911
commit d26c3bd11a
9 changed files with 302 additions and 301 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -23,6 +23,7 @@ using System.Text;
using System.Threading;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Web;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using RestSharp;

View File

@@ -101,12 +101,6 @@ namespace Tribufu.Client
// https://msdn.microsoft.com/en-us/library/az4se3k1(v=vs.110).aspx#Anchor_8
// For example: 2009-06-15T13:45:30.0000000
return dateTimeOffset.ToString((configuration ?? GlobalConfiguration.Instance).DateTimeFormat);
if (obj is DateOnly dateOnly)
// Return a formatted date string - Can be customized with Configuration.DateTimeFormat
// Defaults to an ISO 8601, using the known as a Round-trip date/time pattern ("o")
// https://msdn.microsoft.com/en-us/library/az4se3k1(v=vs.110).aspx#Anchor_8
// For example: 2009-06-15
return dateOnly.ToString((configuration ?? GlobalConfiguration.Instance).DateTimeFormat);
if (obj is bool boolean)
return boolean ? "true" : "false";
if (obj is ICollection collection) {

View File

@@ -53,7 +53,7 @@ namespace Tribufu.Model
/// <param name="viewCount">viewCount.</param>
/// <param name="created">created.</param>
/// <param name="updated">updated.</param>
public Profile(string id = default(string), Guid uuid = default(Guid), string name = default(string), string displayName = default(string), bool verified = default(bool), int level = default(int), double experience = default(double), bool publicBirthday = default(bool), DateOnly? birthday = default(DateOnly?), double points = default(double), string location = default(string), string photoUrl = default(string), string bannerUrl = default(string), DateTime? lastOnline = default(DateTime?), string biography = default(string), int viewCount = default(int), DateTime created = default(DateTime), DateTime? updated = default(DateTime?))
public Profile(string id = default(string), Guid uuid = default(Guid), string name = default(string), string displayName = default(string), bool verified = default(bool), int level = default(int), double experience = default(double), bool publicBirthday = default(bool), DateTime? birthday = default(DateTime?), double points = default(double), string location = default(string), string photoUrl = default(string), string bannerUrl = default(string), DateTime? lastOnline = default(DateTime?), string biography = default(string), int viewCount = default(int), DateTime created = default(DateTime), DateTime? updated = default(DateTime?))
{
this.Id = id;
this.Uuid = uuid;
@@ -127,7 +127,8 @@ namespace Tribufu.Model
/// Gets or Sets Birthday
/// </summary>
[DataMember(Name = "birthday", EmitDefaultValue = true)]
public DateOnly? Birthday { get; set; }
[JsonConverter(typeof(OpenAPIDateConverter))]
public DateTime? Birthday { get; set; }
/// <summary>
/// Gets or Sets Points

View File

@@ -1 +0,0 @@
# Tribufu

View File

@@ -9,12 +9,11 @@
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<IsPublishable>false</IsPublishable>
<Nullable>annotations</Nullable>
<OutputType>Library</OutputType>
<TargetFrameworks>net6.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;net472;net5.0</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<None Include="README.md" Pack="true" PackagePath="\" />
<None Include="..\..\README.md" Pack="true" PackagePath="\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="JsonSubTypes" />

View File

@@ -25,7 +25,7 @@ namespace Tribufu
/// <summary>
/// Create a <see cref="TribufuApi"/> instance.
/// </summary>
public TribufuApi(string? apiKey = null) : base(CreateConfiguration(apiKey))
public TribufuApi(string apiKey = null) : base(CreateConfiguration(apiKey))
{
}
@@ -63,9 +63,12 @@ namespace Tribufu
/// // Environment variable TRIBUFU_API_KEY must be set
/// var api = TribufuApi.FromEnv();
/// </example>
public static TribufuApi? FromEnv(string? prefix = null)
public static TribufuApi FromEnv(string prefix = null)
{
prefix ??= "TRIBUFU";
if (prefix == null)
{
prefix = "TRIBUFU";
}
var apiKey = Environment.GetEnvironmentVariable($"{prefix}_API_KEY");
@@ -110,8 +113,8 @@ namespace Tribufu
{
var version = GetVersion();
var frameworkDescription = RuntimeInformation.FrameworkDescription.Trim();
var runtimeIdentifier = RuntimeInformation.RuntimeIdentifier.Trim();
return $"Tribufu/{version} ({frameworkDescription}; {runtimeIdentifier})";
//var runtimeIdentifier = RuntimeInformation.RuntimeIdentifier.Trim();
return $"Tribufu/{version} ({frameworkDescription})"; //; {runtimeIdentifier})";
}
/// <summary>
@@ -151,7 +154,7 @@ namespace Tribufu
/// <summary>
/// Creates a configuration for the Tribufu API client.
/// </summary>
private static Configuration CreateConfiguration(string? apiKey)
private static Configuration CreateConfiguration(string apiKey)
{
var config = new Configuration
{

View File

@@ -11,14 +11,18 @@ namespace Tribufu
/// </remarks>
public static class TribufuApiSingleton
{
private static TribufuApi? _instance = null;
private static TribufuApi _instance = null;
/// <summary>
/// Get the singleton instance of <see cref="TribufuApi"/>.
/// </summary>
public static TribufuApi GetInstance()
{
_instance ??= TribufuApi.FromEnvOrDefault();
if (_instance == null)
{
_instance = TribufuApi.FromEnvOrDefault();
}
return _instance;
}