<commit_before># stashbox-extensions-dependencyinjection
[![Appveyor build status](https://img.shields.io/appveyor/ci/pcsajtai/stashbox-extensions-dependencyinjection/master.svg?label=appveyor)](https://ci.appveyor.com/project/pcsajtai/stashbox-extensions-dependencyinjection/branch/master) [![Travis CI build status](https://img.shields.io/travis/z4kn4fein/stashbox-extensions-dependencyinjection/master.svg?label=travis-ci)](https://travis-ci.org/z4kn4fein/stashbox-extensions-dependencyinjection)

Stashbox.Extensions.Dependencyinjection: [![NuGet Version](https://buildstats.info/nuget/Stashbox.Extensions.Dependencyinjection)](https://www.nuget.org/packages/Stashbox.Extensions.Dependencyinjection/)

Stashbox.AspNetCore.Hosting: [![NuGet Version](https://buildstats.info/nuget/Stashbox.AspNetCore.Hosting)](https://www.nuget.org/packages/Stashbox.AspNetCore.Hosting/)

[Microsoft.Extensions.DependencyInjection](https://github.com/aspnet/DependencyInjection) and [Microsoft.AspNetCore.Hosting](https://github.com/aspnet/Hosting) `IWebHostBuilder` adapter for ASP.NET Core.

##Registering in Startup.cs
```c#
public class Startup
{
    public IServiceProvider ConfigureServices(IServiceCollection services)
    {
        services.AddSingleton<IService1, IService1>();
        services.AddTransient<..., ...>();
        //etc...
        
        return services.UseStashbox(container =>
        {
            container.RegisterScoped<IService2, Service2>();
            container.RegisterScoped<..., ...>();
            //etc...
        });
    }
}
```
##Registering in the `WebHostBuilder`
```c#
public class Program
{
    public static void Main(string[] args)
    {
        var host = new WebHostBuilder()
        //...
        .UseStashbox(container =>
        {
            container.RegisterScoped<IService1, Service1>();
            //etc...
        })
        //...
        .Build();

        host.Run();
    }
}
```<commit_msg>Update README.md [skip ci]<commit_after># stashbox-extensions-dependencyinjection
[![Appveyor build status](https://img.shields.io/appveyor/ci/pcsajtai/stashbox-extensions-dependencyinjection/master.svg?label=appveyor)](https://ci.appveyor.com/project/pcsajtai/stashbox-extensions-dependencyinjection/branch/master) [![Travis CI build status](https://img.shields.io/travis/z4kn4fein/stashbox-extensions-dependencyinjection/master.svg?label=travis-ci)](https://travis-ci.org/z4kn4fein/stashbox-extensions-dependencyinjection)

Stashbox.Extensions.Dependencyinjection: [![NuGet Version](https://buildstats.info/nuget/Stashbox.Extensions.Dependencyinjection)](https://www.nuget.org/packages/Stashbox.Extensions.Dependencyinjection/)

Stashbox.AspNetCore.Hosting: [![NuGet Version](https://buildstats.info/nuget/Stashbox.AspNetCore.Hosting)](https://www.nuget.org/packages/Stashbox.AspNetCore.Hosting/)

[Microsoft.Extensions.DependencyInjection](https://github.com/aspnet/DependencyInjection) and [Microsoft.AspNetCore.Hosting](https://github.com/aspnet/Hosting) `IWebHostBuilder` adapter for ASP.NET Core.

##Registering in Startup.cs
```c#
public class Startup
{
    public IServiceProvider ConfigureServices(IServiceCollection services)
    {
        services.AddSingleton<IService1, IService1>();
        services.AddTransient<..., ...>();
        //etc...
        
        return services.UseStashbox(container =>
        {
            container.RegisterScoped<IService2, Service2>();
            container.RegisterScoped<..., ...>();
            //etc...
        });
    }
}
```
##Registering in the `WebHostBuilder`
```c#
public class Program
{
    public static void Main(string[] args)
    {
        var host = new WebHostBuilder()
        //...
        .UseStashbox(container =>
        {
            container.RegisterScoped<IService1, Service1>();
            //etc...
        })
        //...
        .Build();

        host.Run();
    }
}
```
##Configuration
You don't have to always use the argument of the `.UseStashbox()` method to configure your service, you can also specify a `ConfigureContainer()` method in your startup class, which will be invoked by the ASP.NET framework itself at the application startup.
```c#
public class Startup
{
    public IServiceProvider ConfigureServices(IServiceCollection services)
    //...
    
    public void ConfigureContainer(IStashboxContainer container)
    {
        container.RegisterScoped<IService1, Service1>();
        //etc...
    }
}
```

####If you want to let Stashbox activate your controllers you should do the following
```c#
public class Startup
{
    public IServiceProvider ConfigureServices(IServiceCollection services)
    {
        services.AddMvc().AddControllersAsServices();
        //etc..-
    }
}
```
{'fraction_non_alphanumeric': 0.1422824475968664, 'fraction_numerical': 0.004658056320135507, 'mean_word_length': 3.4190832553788586, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 18, 'https://': 20, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1105983', 'n_tokens_mistral': 1434, 'n_tokens_neox': 1394, 'n_words': 217}