Methoden hinzugefügt, um DiP-Modus und kombinierten Dev- oder DiP-Modus zu prüfen.

This commit is contained in:
Developer 02 2024-05-22 13:03:51 +02:00
parent 0138fb5166
commit c559662286

View File

@ -19,5 +19,33 @@ namespace DigitalData.Core.API
/// <returns>The application builder with the CSP middleware added.</returns>
public static IApplicationBuilder UseCSPMiddleware(this IApplicationBuilder app, string policy)
=> app.UseMiddleware<CSPMiddleware>(policy);
/// <summary>
/// Checks if the DiP (Development in Production) mode is enabled for the WebApplicationBuilder.
/// </summary>
/// <param name="builder">The WebApplicationBuilder instance.</param>
/// <returns>True if DiP mode is enabled; otherwise, false.</returns>
public static bool IsDiP(this WebApplicationBuilder builder) => builder.Configuration.GetValue<bool>("DiPMode");
/// <summary>
/// Checks if the DiP (Development in Production) mode is enabled for the WebApplication.
/// </summary>
/// <param name="app">The WebApplication instance.</param>
/// <returns>True if DiP mode is enabled; otherwise, false.</returns>
public static bool IsDiP(this WebApplication app) => app.Configuration.GetValue<bool>("DiPMode");
/// <summary>
/// Checks if the environment is Development or DiP (Development in Production) mode is enabled for the WebApplicationBuilder.
/// </summary>
/// <param name="builder">The WebApplicationBuilder instance.</param>
/// <returns>True if the environment is Development or DiP mode is enabled; otherwise, false.</returns>
public static bool IsDevOrDiP(this WebApplicationBuilder builder) => builder.Environment.IsDevelopment() || builder.IsDiP();
/// <summary>
/// Checks if the environment is Development or DiP (Development in Production) mode is enabled for the WebApplication.
/// </summary>
/// <param name="app">The WebApplication instance.</param>
/// <returns>True if the environment is Development or DiP mode is enabled; otherwise, false.</returns>
public static bool IsDevOrDiP(this WebApplication app) => app.Environment.IsDevelopment() || app.IsDiP();
}
}