IApplicationBuilderUsed to configure the application middleware pipelineMap() -> IApplicationBuilderMapWhen() -> IApplicationBuilderRun() -> voidUse() -> IApplicationBuilderUseMiddleware() -> IApplicationBuilderUsePathBase() -> IApplicationBuilderUseRouting() -> IApplicationBuilderUseRouter(Action<IRouteBuilder> action) -> IApplicationBuilderUseEndpointPoints() -> IApplicationBuilder
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!-- Put this in sub-directory of the project named 'assets' --> | |
| <Project> | |
| <Target Name="_ExtractVersionMetadata"> | |
| <WriteLinesToFile File="$(_ProjectVersionMetadataFile)" Lines="$(Version)" /> | |
| </Target> | |
| </Project> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System.Buffers.Text; | |
| using System.Text; | |
| using System.Text.Json; | |
| using System.Text.Json.Serialization; | |
| using Microsoft.AspNetCore.Authentication; | |
| using Microsoft.AspNetCore.Authentication.JwtBearer; | |
| using Microsoft.AspNetCore.Authorization; | |
| using Microsoft.Extensions.Options; | |
| using Microsoft.OpenApi.Models; | |
| using Swashbuckle.AspNetCore.SwaggerGen; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| app.MapGroup("/apis", apis => | |
| { | |
| apis.UseExceptionHandler("/error"); | |
| var problemJsonMediaType = new MediaTypeHeaderValue("application/problem+json"); | |
| apis.MapGet("/error", (HttpContext context) => | |
| { | |
| // Get exception details | |
| var error = context.Features.Get<IExceptionHandlerFeature>()?.Error; | |
| var badRequestEx = error as BadHttpRequestException; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Now | |
| app.MapGet("/todos/{id}", async (int id, TodoDb db) => | |
| await db.Todos.FindAsync(id) | |
| is Todo todo | |
| ? Results.Ok(todo) | |
| : Results.NotFound()) | |
| .WithName("GetTodoById") | |
| .Produces<Todo>(StatusCodes.Status200OK) | |
| .Produces(StatusCodes.Status404NotFound); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Ref: https://github.com/cston/csharplang/blob/DiscriminatedUnions/proposals/tagged-unions.md | |
| using System.ComponentModel.DataAnnotations; | |
| using Microsoft.EntityFrameworkCore; | |
| using MiniValidation; | |
| var builder = WebApplication.CreateBuilder(args); | |
| var connectionString = builder.Configuration.GetConnectionString("TodoDb") ?? "Data Source=todos.db"; | |
| builder.Services.AddSqlite<TodoDb>(connectionString); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function Get-ProgramFiles32() { | |
| if ($null -ne ${env:ProgramFiles(x86)}) { | |
| return ${env:ProgramFiles(x86)} | |
| } | |
| return $env:ProgramFiles | |
| } | |
| function Get-VsInstallLocation() { | |
| $programFiles = Get-ProgramFiles32 | |
| $vswhere = "$programFiles\Microsoft Visual Studio\Installer\vswhere.exe" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json", | |
| "blocks": [ | |
| { | |
| "alignment": "left", | |
| "segments": [ | |
| { | |
| "foreground": "#f1184c", | |
| "properties": { | |
| "template": " \uf0e7 " |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "type": "text", // VS version | |
| "style": "powerline", | |
| "powerline_symbol": "\uE0C4", | |
| "foreground": "#ffffff", | |
| "background": "#5C2D91", // VS purple from https://visualstudio.microsoft.com/ | |
| "properties": { | |
| "prefix": "", | |
| "text": "{{if .Env.VSCMD_VER}} {{.Env.VSCMD_VER}} {{end}}", | |
| "postfix": "" |