Skip to content

Instantly share code, notes, and snippets.

@lakeman
lakeman / Impersonate.cs
Created November 24, 2017 14:08
Win32 Impersonate Middleware
public class Impersonate
{
private readonly RequestDelegate next;
private ILogger<Impersonate> logger;
private readonly IServiceProvider _provider;
public Impersonate(ILogger<Impersonate> logger, RequestDelegate next, IServiceProvider provider) {
this.next = next;
this.logger = logger;
public class EndpointInit
{
private readonly IServiceProvider provider;
private readonly IActionDescriptorCollectionProvider collectionProvider;
private readonly IActionInvokerFactory invokerFactory;
private readonly PageLoader pageLoader;
public EndpointInit(IServiceProvider provider, IActionDescriptorCollectionProvider collectionProvider, IActionInvokerFactory invokerFactory, PageLoader pageLoader)
{
this.provider = provider;
@lakeman
lakeman / AutoMigration.cs
Last active October 9, 2023 00:30
Automatic database migration with EF Core 3.0
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Design.Internal;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Migrations.Design;
using Microsoft.EntityFrameworkCore.Migrations.Operations;
using Microsoft.EntityFrameworkCore.Storage;