Lex45x / Grace.DependencyInjection.Extensions

Grace Extensions for ASP.Net Core

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Extensions for using Grace in ASP.Net Core

Using Grace in an ASP.Net Core application is really simple, add the Grace.AspNetCore.Hosting package. Then add the following to your project

Program.cs

var host = new WebHostBuilder()
                .UseKestrel()
                .UseContentRoot(Directory.GetCurrentDirectory())
                .UseIISIntegration()
                .UseGrace()  // add grace
                .UseStartup<Startup>()
                .Build();

When using with .Net Core 3.x, make sure to UseGrace() from the IHostBuilder, not the IWebHostBuilder:

 public static IHostBuilder CreateHostBuilder(string[] args) =>
            Host.CreateDefaultBuilder(args)
                // UseGrace() goes here
                .UseGrace()
                .ConfigureWebHostDefaults(webBuilder =>
                {
                    webBuilder
                        // UseGrace() doesn't go here
                        .UseStartup<Startup>();
                });

Startup.cs

public void ConfigureServices(IServiceCollection services)
{
  services.AddMvc();
}

// add this method
public void ConfigureContainer(IInjectionScope scope)
{
   // add your registrations here
}

Grace provides custom controller and view activators providing better performance some custom features.

Add the Grace.AspNetCore.MVC nuget package.

Startup.cs

public void ConfigureContainer(IInjectionScope scope)
{
  scope.SetupMvc();
  
   // add your registrations here
}

Note: .net core 1.0 support will be removed in version 7.1.0

Build status

About

Grace Extensions for ASP.Net Core


Languages

Language:C# 100.0%