Skip to content

Commit fae0103

Browse files
committed
Rewrite GitService for convenience
1 parent da1e070 commit fae0103

File tree

13 files changed

+1843
-383
lines changed

13 files changed

+1843
-383
lines changed
Lines changed: 35 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,35 @@
1-
// ============================================================================
2-
// Copyright (c) 2024 - W2Wizard.
3-
// See README.md in the project root for license information.
4-
// ============================================================================
5-
6-
namespace NXTBackend.API.Options;
7-
8-
// ============================================================================
9-
10-
public class GitRemoteOptions
11-
{
12-
public string? DefaultBranch { get; set; } = "main";
13-
public required string ApiUrl { get; set; }
14-
}
15-
16-
// ============================================================================
17-
18-
public static class ConfigurationExtensions
19-
{
20-
/// <summary>
21-
/// Retrieves the Keycloak options from the configuration section with the specified name.
22-
/// </summary>
23-
/// <typeparam name="T">The type of the Keycloak options.</typeparam>
24-
/// <param name="configuration">The configuration instance.</param>
25-
/// <param name="configSectionName">The name of the configuration section. Default is ConfigurationConstants.ConfigurationPrefix.</param>
26-
/// <returns>The Keycloak options instance.</returns>
27-
public static T? GetGitRemoteOptions<T>(this IConfiguration configuration, string configSectionName = "GitRemote") where T : GitRemoteOptions
28-
{
29-
ArgumentNullException.ThrowIfNull(configuration);
30-
return configuration.GetSection(configSectionName).Get<T>();
31-
}
32-
}
1+
// ============================================================================
2+
// Copyright (c) 2024 - W2Wizard.
3+
// See README.md in the project root for license information.
4+
// ============================================================================
5+
6+
using Microsoft.Extensions.Configuration;
7+
8+
namespace NXTBackend.API.Core.Options;
9+
10+
// ============================================================================
11+
12+
public class GitRemoteOptions
13+
{
14+
public string? DefaultBranch { get; set; } = "main";
15+
public required string ApiUrl { get; set; }
16+
public required string Template { get; set; }
17+
}
18+
19+
// ============================================================================
20+
21+
public static class ConfigurationExtensions
22+
{
23+
/// <summary>
24+
/// Retrieves the Keycloak options from the configuration section with the specified name.
25+
/// </summary>
26+
/// <typeparam name="T">The type of the Keycloak options.</typeparam>
27+
/// <param name="configuration">The configuration instance.</param>
28+
/// <param name="configSectionName">The name of the configuration section. Default is ConfigurationConstants.ConfigurationPrefix.</param>
29+
/// <returns>The Keycloak options instance.</returns>
30+
public static T? GetGitRemoteOptions<T>(this IConfiguration configuration, string configSectionName = "GitRemote") where T : GitRemoteOptions
31+
{
32+
ArgumentNullException.ThrowIfNull(configuration);
33+
return configuration.GetSection(configSectionName).Get<T>();
34+
}
35+
}

0 commit comments

Comments
 (0)