$mermaidjs
Clean Architecture Demo
Loading...
Searching...
No Matches
Program.cs File Reference

Go to the source code of this file.

Classes

class  Program
 Partial Program class made public for testing purposes. Allows WebApplicationFactory to access the Program configuration in integration tests. More...
 

Typedefs

using scope = app.Services.CreateScope()) { var dbContext=scope.ServiceProvider.GetRequiredService< TaskDbContext >()
 

Functions

builder.Configuration. AddUserSecrets (Assembly.GetExecutingAssembly(), optional:true)
 
builder.Configuration. AddInMemoryCollection (new Dictionary< string, string?> {["ConnectionStrings:DefaultConnection"]=connectionString })
 
builder.Services. AddSingleton< SqliteConnection > (_=> { var connection=new SqliteConnection(connectionString);connection.Open();return connection;})
 
builder.Services. AddAuthentication (JwtBearerDefaults.AuthenticationScheme) .AddJwtBearer(options
 
builder.Services. AddAuthorization ()
 
builder.Services. AddMediatR (cfg=> cfg.RegisterServicesFromAssembly(typeof(TaskManagement.Application.Commands.CreateTaskCommand).Assembly)) .AddValidatorsFromAssembly(typeof(TaskManagement.Application.Commands.CreateTaskCommand).Assembly) .AddTransient(typeof(IPipelineBehavior<
 
builder.Services. typeof (ValidationBehavior<,>)) .AddDbContext< TaskDbContext >(options
 
dbContext.Database. EnsureCreated ()
 
app. UseMiddleware< ExceptionHandlingMiddleware > ()
 
app. UseHttpsRedirection ()
 
app. UseAuthentication ()
 
app. UseAuthorization ()
 
app. MapControllers ()
 
app. Run ()
 

Variables

var builder = WebApplication.CreateBuilder(args)
 
const string connectionString = "Data Source=file:taskmanagement?mode=memory&cache=shared"
 
var bearerSection = builder.Configuration.GetSection("Authentication:Schemes:Bearer")
 
var validIssuer = bearerSection["ValidIssuer"]
 
var validAudiences
 
var signingKeys
 
var app = builder.Build()
 

Typedef Documentation

◆ scope

using scope = app.Services.CreateScope()) { var dbContext = scope.ServiceProvider.GetRequiredService<TaskDbContext>()

Definition at line 120 of file Program.cs.

Function Documentation

◆ AddAuthentication()

builder.Services. AddAuthentication ( JwtBearerDefaults.  AuthenticationScheme)

◆ AddAuthorization()

builder.Services. AddAuthorization ( )

◆ AddInMemoryCollection()

builder.Configuration. AddInMemoryCollection ( new Dictionary< string, string?> {["ConnectionStrings:DefaultConnection"]=connectionString )

◆ AddMediatR()

builder.Services. AddMediatR ( cfg  ,
cfg::RegisterServicesFromAssembly(typeof(TaskManagement.Application.Commands.CreateTaskCommand).Assembly)   
)

◆ AddSingleton< SqliteConnection >()

builder.Services. AddSingleton< SqliteConnection > ( ,
{ var connection=new SqliteConnection(connectionString);connection.Open();return connection;}   
)

◆ AddUserSecrets()

builder.Configuration. AddUserSecrets ( Assembly.  GetExecutingAssembly(),
optional:true   
)

◆ EnsureCreated()

dbContext.Database. EnsureCreated ( )

◆ MapControllers()

app. MapControllers ( )

◆ Run()

app. Run ( )

◆ typeof()

builder.Services. typeof ( ValidationBehavior<,>  )

◆ UseAuthentication()

app. UseAuthentication ( )

◆ UseAuthorization()

app. UseAuthorization ( )

◆ UseHttpsRedirection()

app. UseHttpsRedirection ( )

◆ UseMiddleware< ExceptionHandlingMiddleware >()

app. UseMiddleware< ExceptionHandlingMiddleware > ( )

Variable Documentation

◆ app

var app = builder.Build()

Definition at line 118 of file Program.cs.

◆ bearerSection

var bearerSection = builder.Configuration.GetSection("Authentication:Schemes:Bearer")

Definition at line 72 of file Program.cs.

◆ builder

var builder = WebApplication.CreateBuilder(args)

Definition at line 55 of file Program.cs.

◆ connectionString

const string connectionString = "Data Source=file:taskmanagement?mode=memory&cache=shared"
static

Definition at line 61 of file Program.cs.

◆ signingKeys

var signingKeys
Initial value:
.GetSection("SigningKeys")
.GetChildren()
.Select(x => x["Value"])
.Where(x => !string.IsNullOrWhiteSpace(x))
.Select(x => new SymmetricSecurityKey(Convert.FromBase64String(x!)))
.Cast<SecurityKey>()
.ToArray()
var bearerSection
Definition Program.cs:72

Definition at line 77 of file Program.cs.

◆ validAudiences

var validAudiences
Initial value:
.GetSection("ValidAudiences")
.Get<string[]>() ?? []

Definition at line 74 of file Program.cs.

◆ validIssuer

var validIssuer = bearerSection["ValidIssuer"]

Definition at line 73 of file Program.cs.