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
<?xml version="1.0" encoding="utf-8" ?> | |
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" | |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
autoReload="true" | |
internalLogLevel="Warn" | |
internalLogFile="C:\git\dotnetconf\001-logging\internal-nlog.txt"> | |
<!-- Load the ASP.NET Core plugin --> | |
<extensions> | |
<add assembly="NLog.Web.AspNetCore"/> |
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.Collections.Concurrent; | |
namespace LoggingSample; | |
public class ColoredConsoleLoggerConfiguration | |
{ | |
public LogLevel LogLevel { get; set; } = LogLevel.Warning; | |
public int EventId { get; set; } = 0; | |
public ConsoleColor Color { get; set; } = ConsoleColor.Yellow; | |
} |
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; | |
using System.Threading; | |
using System.Threading.Tasks; | |
using Microsoft.Extensions.Hosting; | |
using Microsoft.Extensions.Logging; | |
namespace HostedServiceSample | |
{ | |
public class SampleHostedService : IHostedService | |
{ |
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
public class StopwatchMiddleWare | |
{ | |
private readonly RequestDelegate _next; | |
public StopwatchMiddleWare(RequestDelegate next) | |
{ | |
_next = next; | |
} | |
public async Task Invoke(HttpContext context) |
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.Text; | |
using Microsoft.AspNetCore.Mvc.Formatters; | |
using Microsoft.Net.Http.Headers; | |
using OutputFormatterSample.Models; | |
namespace OutputFormatterSample; | |
public class VcardOutputFormatter : TextOutputFormatter | |
{ | |
public string ContentType { get; } = "text/vcard"; |
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.Globalization; | |
using System.Text; | |
using CsvHelper; | |
using Microsoft.AspNetCore.Mvc.Formatters; | |
using Microsoft.Net.Http.Headers; | |
using OutputFormatterSample.Models; | |
namespace OutputFormatterSample; | |
public class CsvOutputFormatter : TextOutputFormatter |
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
namespace HostedServiceSample; | |
public class SampleBackgroundService : BackgroundService | |
{ | |
private readonly ILogger<SampleHostedService> logger; | |
public SampleBackgroundService(ILogger<SampleHostedService> logger) | |
{ | |
this.logger = logger; | |
} |
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
namespace RoutingSample; | |
public class MyHealthChecksMiddleware | |
{ | |
private readonly ILogger<MyHealthChecksMiddleware> _logger; | |
public MyHealthChecksMiddleware( | |
RequestDelegate next, | |
ILogger<MyHealthChecksMiddleware> logger) | |
{ |
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
namespace RoutingSample; | |
public static class MapMyHealthChecksExtensions | |
{ | |
public static IEndpointConventionBuilder MapMyHealthChecks( | |
this IEndpointRouteBuilder endpoints, string pattern = "/myhealth") | |
{ | |
var pipeline = endpoints | |
.CreateApplicationBuilder() | |
.UseMiddleware<MyHealthChecksMiddleware>() | |
.Build(); |
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
public class PersonsCsvBinder : IModelBinder | |
{ | |
public Task BindModelAsync(ModelBindingContext bindingContext) | |
{ | |
if (bindingContext == null) | |
{ | |
throw new ArgumentNullException(nameof(bindingContext)); | |
} | |
// Specify a default argument name if none is set by ModelBinderAttribute |
OlderNewer