Remove Extensions class and update namespace references from Helpers to Helper for consistency

This commit is contained in:
Andre Beging
2025-12-11 19:06:41 +01:00
parent 46229a6dc7
commit 05b92e8f54
9 changed files with 11 additions and 52 deletions

View File

@@ -2,7 +2,7 @@ using System.Text.Json;
using System.Text.Json.Nodes;
using FsToolbox.Cli.Tasks;
namespace FsToolbox.Cli.Helpers
namespace FsToolbox.Cli.Helper
{
/// <summary>
/// Provides helper methods to manage authentication and cached CSRF tokens.

View File

@@ -1,41 +0,0 @@
using System.Text;
using System.Text.Json.Nodes;
namespace FsToolbox.Cli.Helpers
{
public static class Extensions
{
#region Public Method FsPostAsync
/// <summary>
/// Sends a POST request to the specified URI with the provided JSON content.
/// </summary>
/// <param name="httpClient">The instance of <see cref="HttpClient" /> used to send the request.</param>
/// <param name="requestUri">The URI to which the request is sent.</param>
/// <param name="jsonObject">The JSON object to include in the request body.</param>
/// <returns>A task that represents the asynchronous operation. The task result contains the HTTP response.</returns>
public static async Task<HttpResponseMessage> FsPostAsync(this HttpClient httpClient, string requestUri, JsonObject jsonObject)
{
var content = new StringContent(jsonObject.ToString(), Encoding.UTF8, "application/json");
content.Headers.ContentType = new("application/json");
return await httpClient.PostAsync(requestUri, content);
}
#endregion
#region Public Method ToList
/// <summary>
/// Converts the specified JSON node into a list of non-null <see cref="JsonNode" /> elements.
/// </summary>
/// <param name="node">The <see cref="JsonNode" /> to be converted. If null, an empty list is returned.</param>
/// <returns>A list of <see cref="JsonNode" /> instances containing non-null elements.</returns>
public static List<JsonNode> ToList(this JsonNode? node)
{
var array = node?.AsArray() ?? [];
return array.Where(x => x != null).Select(x => x!).ToList();
}
#endregion
}
}

View File

@@ -1,6 +1,6 @@
using Microsoft.Extensions.Configuration;
namespace FsToolbox.Cli.Helpers
namespace FsToolbox.Cli.Helper
{
/// <summary>
/// Represents the root configuration settings for the application, including API and credentials.