Class ApiStartupBase
Base class for configuring API startup settings and dependencies.
Inherited Members
Namespace: Innovt.AspNetCore
Assembly: Innovt.AspNetCore.dll
Syntax
public abstract class ApiStartupBase
Constructors
| Edit this page View SourceApiStartupBase(IConfiguration, IWebHostEnvironment, string, bool)
Initializes a new instance of the ApiStartupBase class with the specified configuration and environment.
Declaration
protected ApiStartupBase(IConfiguration configuration, IWebHostEnvironment environment, string appName, bool setDefaultJsonOptions = true)
Parameters
Type | Name | Description |
---|---|---|
IConfiguration | configuration | The configuration for the application. |
IWebHostEnvironment | environment | The hosting environment for the application. |
string | appName | The name of the application. |
bool | setDefaultJsonOptions | This is the default convention for Serialization/Deserialization |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown if configuration, environment, or appName is null. |
ApiStartupBase(IConfiguration, IWebHostEnvironment, string, string, string, string, string?, string?, bool)
Initializes a new instance of the ApiStartupBase class with additional API documentation details.
Declaration
protected ApiStartupBase(IConfiguration configuration, IWebHostEnvironment environment, string appName, string apiTitle, string apiDescription, string apiVersion, string? contactName = null, string? contactEmail = null, bool setDefaultJsonOptions = true)
Parameters
Type | Name | Description |
---|---|---|
IConfiguration | configuration | The configuration for the application. |
IWebHostEnvironment | environment | The hosting environment for the application. |
string | appName | The name of the application. |
string | apiTitle | The title of the API. |
string | apiDescription | The description of the API. |
string | apiVersion | The version of the API. |
string | contactName | The name of the API contact (optional). |
string | contactEmail | The email of the API contact (optional). |
bool | setDefaultJsonOptions | This is the default convention for Serialization/Deserialization |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown if configuration, environment, appName, apiTitle, apiDescription, or apiVersion is null. |
Properties
| Edit this page View SourceAppName
Gets the name of the application.
Declaration
public string AppName { get; }
Property Value
Type | Description |
---|---|
string |
Configuration
Gets the configuration for the application.
Declaration
public IConfiguration Configuration { get; }
Property Value
Type | Description |
---|---|
IConfiguration |
DefaultHealthPath
Gets or sets the default health path for the application.
Declaration
protected string DefaultHealthPath { get; set; }
Property Value
Type | Description |
---|---|
string |
Documentation
Gets or sets the API documentation details.
Declaration
protected DefaultApiDocumentation Documentation { get; set; }
Property Value
Type | Description |
---|---|
DefaultApiDocumentation |
Environment
Gets the hosting environment for the application.
Declaration
public IWebHostEnvironment Environment { get; }
Property Value
Type | Description |
---|---|
IWebHostEnvironment |
Localization
Gets or sets the localization settings for the API.
Declaration
protected DefaultApiLocalization Localization { get; set; }
Property Value
Type | Description |
---|---|
DefaultApiLocalization |
SetDefaultJsonOptions
If true will set default Json Options(JsonSerializerOptions.PropertyNamingPolicy = JsonNamingPolicy.CamelCase) etc
Declaration
public bool SetDefaultJsonOptions { get; set; }
Property Value
Type | Description |
---|---|
bool |
Methods
| Edit this page View SourceAddDefaultServices(IServiceCollection)
Adds default services to the service collection.
Declaration
protected abstract void AddDefaultServices(IServiceCollection services)
Parameters
Type | Name | Description |
---|---|---|
IServiceCollection | services | The service collection to add default services to. |
AddSwagger(IServiceCollection)
Adds Swagger generation to the specified services.
Declaration
protected virtual void AddSwagger(IServiceCollection services)
Parameters
Type | Name | Description |
---|---|---|
IServiceCollection | services | The service collection to add Swagger to. |
AddTracing(IServiceCollection)
Adds tracing and telemetry to the specified services.
Declaration
protected virtual void AddTracing(IServiceCollection services)
Parameters
Type | Name | Description |
---|---|---|
IServiceCollection | services | The service collection to add tracing to. |
Configure(IApplicationBuilder, IWebHostEnvironment, ILoggerFactory)
Configure Will Add All main Services as Default for Api and MVC Applications
Declaration
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory)
Parameters
Type | Name | Description |
---|---|---|
IApplicationBuilder | app | |
IWebHostEnvironment | env | |
ILoggerFactory | loggerFactory |
ConfigureApiBehavior()
Configures API behavior options.
Declaration
protected virtual Action<ApiBehaviorOptions> ConfigureApiBehavior()
Returns
Type | Description |
---|---|
Action<ApiBehaviorOptions> | An action that configures ApiBehaviorOptions. |
ConfigureApp(IApplicationBuilder, IWebHostEnvironment, ILoggerFactory)
Configures the application.
Declaration
public abstract void ConfigureApp(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory)
Parameters
Type | Name | Description |
---|---|---|
IApplicationBuilder | app | The application builder. |
IWebHostEnvironment | env | The hosting environment. |
ILoggerFactory | loggerFactory | The logger factory. |
ConfigureCultures(IApplicationBuilder)
Configures request cultures for the application.
Declaration
protected virtual void ConfigureCultures(IApplicationBuilder app)
Parameters
Type | Name | Description |
---|---|---|
IApplicationBuilder | app | The application builder. |
ConfigureHealthChecks(IServiceCollection)
Implement only the AddHealthChecks by default
Declaration
protected virtual void ConfigureHealthChecks(IServiceCollection services)
Parameters
Type | Name | Description |
---|---|---|
IServiceCollection | services |
ConfigureIoC(IServiceCollection)
Configures the IoC container for the application.
Declaration
protected abstract void ConfigureIoC(IServiceCollection services)
Parameters
Type | Name | Description |
---|---|---|
IServiceCollection | services | The service collection to configure for IoC. |
ConfigureOpenTelemetry(TracerProviderBuilder)
Configures OpenTelemetry for tracing.
Declaration
protected abstract void ConfigureOpenTelemetry(TracerProviderBuilder builder)
Parameters
Type | Name | Description |
---|---|---|
TracerProviderBuilder | builder | The TracerProviderBuilder for configuring tracing. |
ConfigureServices(IServiceCollection)
Configure services will register default services for api and mvc applications. AddHealthChecks
Declaration
public virtual void ConfigureServices(IServiceCollection services)
Parameters
Type | Name | Description |
---|---|---|
IServiceCollection | services |
ConfigureSwaggerUi(IApplicationBuilder, IWebHostEnvironment)
Configures Swagger UI for API documentation.
Declaration
protected virtual void ConfigureSwaggerUi(IApplicationBuilder app, IWebHostEnvironment env)
Parameters
Type | Name | Description |
---|---|---|
IApplicationBuilder | app | The application builder. |
IWebHostEnvironment | env | The hosting environment. |
IsDevelopmentEnvironment()
Checks if the application is running in a development environment.
Declaration
protected bool IsDevelopmentEnvironment()
Returns
Type | Description |
---|---|
bool | True if the application is in development; otherwise, false. |