KickStart 9.3.0

dotnet add package KickStart --version 9.3.0                
NuGet\Install-Package KickStart -Version 9.3.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="KickStart" Version="9.3.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add KickStart --version 9.3.0                
#r "nuget: KickStart, 9.3.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install KickStart as a Cake Addin
#addin nuget:?package=KickStart&version=9.3.0

// Install KickStart as a Cake Tool
#tool nuget:?package=KickStart&version=9.3.0                

KickStart

Application start-up helper to initialize things like an IoC container, register mapping information or run a task.

Build status

Coverage Status

Package Version
KickStart KickStart
KickStart.Autofac KickStart.Autofac
KickStart.AutoMapper KickStart.AutoMapper
KickStart.DependencyInjection KickStart.DependencyInjection
KickStart.MongoDB KickStart.MongoDB
KickStart.Ninject KickStart.Ninject
KickStart.SimpleInjector KickStart.SimpleInjector
KickStart.Unity KickStart.Unity

Download

The KickStart library is available on nuget.org via package name KickStart.

To install KickStart, run the following command in the Package Manager Console

PM> Install-Package KickStart

More information about NuGet package available at https://nuget.org/packages/KickStart

Development Builds

Development builds are available on the feedz.io feed. A development build is promoted to the main NuGet feed when it's determined to be stable.

In your Package Manager settings add the following package source for development builds: https://f.feedz.io/loresoft/open/nuget/index.json

Features

  • Run tasks on application start-up
  • Extension model to add library specific start up tasks
  • Common IoC container adaptor based on IServiceProvider
  • Singleton instance of an application level IoC container Kick.ServiceProvider

Example

This example will scan the assembly containing UserModule. Then it will find all Autofac modules and register them with Autofac. Then, all AutoMapper profiles will be registered with Automapper. Finally, it will find all classes that implement IStartupTask and run it.

Kick.Start(config => config
    .IncludeAssemblyFor<UserModule>()
    .UseAutofac()
    .UseAutoMapper()
    .UseStartupTask()
);

Pass data to the startup modules

Kick.Start(config => config
    .Data("environment", "debug")
    .Data(d =>
    {
        d["key"] = 123;
        d["server"] = "master";
    })
);

Extensions

  • StartupTask - Run any class that implements IStartupTask
  • Autofac - Registers all Autofac Module classes and creates the container
  • AutoMapper - Registers all AutoMapper Profile classes
  • DependencyInjection - Register all IDependencyInjectionRegistration instances for Microsoft.Extensions.DependencyInjection
  • MongoDB - Registers all BsonClassMap classes with MongoDB serialization
  • Ninject - Registers all NinjectModule classes and creates an IKernal
  • SimpleInjector - Run all ISimpleInjectorRegistration instances allowing container registration
  • Unity - Run all IUnityRegistration instances allowing container registration

StartupTask

The StartupTask extension allows running code on application start-up. To use this extension, implement the IStartupTask interface. Use the Priority property to control the order of execution.

Basic usage

Kick.Start(config => config
    .IncludeAssemblyFor<UserModule>() // where to look for tasks
    .UseStartupTask() // include startup tasks in the Kick Start
);

Run a delegate on startup

Kick.Start(config => config
    .IncludeAssemblyFor<UserModule>()
    .UseAutofac() // init Autofac or any other IoC as container
    .UseStartupTask(c => c =>
    {
        c.Run((services, data) =>
        {
            //do work here
        });
    })
);

Autofac

The Autofac extension allows registration of types to be resolved. The extension also creates a default container and sets it to the Kick.Container singleton for access later.

Basic usage

Kick.Start(config => config
    .IncludeAssemblyFor<UserRepository>() // where to look for tasks
    .UseAutofac() // initialize Autofac
);

Use with ASP.NET MVC

Kick.Start(c => c
    .IncludeAssemblyFor<UserModule>()
    .UseAutofac(a => a
        .Initialize(b => b.RegisterControllers(typeof(MvcApplication).Assembly)) // register all controllers 
        .Container(r => DependencyResolver.SetResolver(new AutofacDependencyResolver(r))) // set asp.net resolver
    )
    .UseAutoMapper()
    .UseMongoDB()
    .UseStartupTask()
);

To install Autofac extension, run the following command in the Package Manager Console

PM> Install-Package KickStart.Autofac

DependencyInjection

The DependencyInjection extension allows using Microsoft.Extensions.DependencyInjection for depenancy injection.

Basic Usage

Kick.Start(config => config
    .LogTo(_output.WriteLine)
    .IncludeAssemblyFor<UserRepository>() // where to look
    .UseDependencyInjection() // initialize DependencyInjection
);

Integrate with asp.net core 2.0

public class Startup
{
    public Startup(IConfiguration configuration)
    {
        Configuration = configuration;
    }

    public IConfiguration Configuration { get; }

    // This method gets called by the runtime. Use this method to add services to the container.
    public void ConfigureServices(IServiceCollection services)
    {
        // this will auto register logging and run the DependencyInjection startup
        services.KickStart(c => c
            .IncludeAssemblyFor<UserRepository>() // where to look
            .Data("configuration", Configuration) // pass configuration to all startup modules
            .Data("hostProcess", "web") // used for conditional registration
            .UseStartupTask() // run startup task
        );
    }
}

To install DependencyInjection extension, run the following command in the Package Manager Console

PM> Install-Package KickStart.DependencyInjection

SimpleInjector

The SimpleInjector extension allows registration of types to be resolved by running all instances of ISimpleInjectorRegistration. The extension also creates a default container and sets it to the Kick.Container singleton for access later.

Basic usage

Kick.Start(config => config
    .IncludeAssemblyFor<UserRepository>() // where to look
    .UseSimpleInjector () // initialize SimpleInjector
);

Using SimpleInjector with ASP.NET WebAPI

Kick.Start(c => c
    .LogTo(_logger.Debug)
    .IncludeAssemblyFor<UserModule>()
    .Data("hostProcess", "web")
    .UseSimpleInjector(s => s
        .Verify(VerificationOption.VerifyOnly)
        .Initialize(container =>
        {
            container.Options.DefaultScopedLifestyle = new WebApiRequestLifestyle();
            container.RegisterWebApiControllers(httpConfiguration); // register all controllers
        })
        .Container(container =>
        {
            httpConfiguration.DependencyResolver = new SimpleInjectorWebApiDependencyResolver(container); // set asp.net resolver
        })
    )
    .UseStartupTask()
);

To install SimpleInjector extension, run the following command in the Package Manager Console

PM> Install-Package KickStart.SimpleInjector

Unity

The Unity extension allows registration of types to be resolved by running all instances of IUnityRegistration. The extension also creates a default container and sets it to the Kick.Container singleton for access later.

Basic usage

Kick.Start(config => config
    .IncludeAssemblyFor<UserRepository>() // where to look
    .UseUnity () // initialize Unity
);

To install Unity extension, run the following command in the Package Manager Console

PM> Install-Package KickStart.Unity

xUnit

Example of bootstraping and logging with xUnit tests.

public class StartupTaskStarterTest
{
    private readonly ITestOutputHelper _output;

    public StartupTaskStarterTest(ITestOutputHelper output)
    {
        _output = output;

        // bootstrap project
        Kick.Start(config => config
            .LogTo(_output.WriteLine)
            .Data("environment", "test") // pass data for conditional registration
            .IncludeAssemblyFor<UserRepository>()
            .UseSimpleInjector () // initialize SimpleInjector
            .UseStartupTask()
        );

    }

    [Fact]
    public void RunTest()
    {
        var userRepository = Kick.ServiceProvider.GetService<IUserRepository>();
        Assert.NotNull(userRepository);

        // more tests
    }
}

Generic Service Registration

KickStart has a generic service registration abstraction. This allows for the creation of a generic class module that registers services for dependency injection that is container agnostic.

Example module to register services

public class UserServiceModule : IServiceModule
{
    public void Register(IServiceRegistration services, IDictionary<string, object> data)
    {
        services.RegisterSingleton<IConnection, SampleConnection>();
        services.RegisterTransient<IUserService, UserService>(c => new UserService(c.GetService<IConnection>()));

        // register all types that are assignable to IService
        services.RegisterSingleton(r => r
            .Types(t => t.AssignableTo<IService>())
            .As(s => s.Self().ImplementedInterfaces())
        );

        // register all types that are assignable to IVehicle
        services.RegisterSingleton(r => r
            .Types(t => t.AssignableTo<IVehicle>())
            .As(s => s.Self().ImplementedInterfaces())
        );
    }
}

Change Log

Version 7.0

  • drop net45 and netstandard1.5 support

Version 6.0

  • add assembly scanning for generic service registration
  • [Breaking] internal change to Context. Property Assemblies changed to Types.

Version 5.0

  • update to .net core 2

Version 4.0

  • [Breaking] Removed IContainerAdaptor and changed to use IServiceProvider instead
  • [Breaking] Renamed Kick.Container to Kick.ServiceProvider
  • [Breaking] Removed logging abstractions. Logging is now a simple Action<string> delegate
  • [Breaking] changed object creation to use ServiceProvider by default
  • [Breaking] changed IStartupTask.Run to IStartupTask.RunAsync
  • changed startup tasks that run async and in parallel by Priority
  • added shared data dictionary that is passed to all startup modules
  • added delegate based startup action
  • added IServiceModule and IServiceRegistration to abstract service/container registration
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

    • No dependencies.
  • net6.0

    • No dependencies.
  • net8.0

    • No dependencies.

NuGet packages (11)

Showing the top 5 NuGet packages that depend on KickStart:

Package Downloads
KickStart.Autofac

KickStart Extension for Autofac

KickStart.AutoMapper

KickStart Extension for AutoMapper

KickStart.MongoDB

KickStart Extension for MongoDB

KickStart.Unity

KickStart Extension for Unity

KickStart.SimpleInjector

KickStart Extension for SimpleInjector

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
9.3.0 508 9/10/2024
9.2.0 491 6/6/2024
9.1.0 1,467 7/28/2023
9.0.548 3,293 8/20/2022
9.0.511 3,445 4/23/2022
9.0.484 3,648 1/18/2022
9.0.476 1,908 12/22/2021
9.0.467 2,186 11/10/2021
8.1.457 2,146 11/4/2021
8.0.0.448 2,379 10/17/2021
8.0.0.433 2,373 7/28/2021
8.0.0.426 2,382 7/9/2021
8.0.0.379 4,090 2/15/2021
8.0.0.369 2,527 1/19/2021
8.0.0.360 2,512 12/9/2020
8.0.0.345 2,751 11/13/2020
8.0.0.334 2,597 10/26/2020
8.0.0.328 2,641 10/17/2020
8.0.0.317 2,642 10/2/2020
8.0.0.310 2,572 9/21/2020
8.0.0.279 2,778 7/19/2020
8.0.0.272 2,712 7/6/2020
8.0.0.266 2,745 6/25/2020
8.0.0.265 2,802 6/25/2020
8.0.0.262 2,912 6/13/2020
8.0.0.221 3,663 4/11/2020
8.0.0.181 3,117 1/24/2020
8.0.0.174 2,938 1/7/2020
8.0.0.171 2,900 1/6/2020
8.0.0.162 2,934 12/15/2019
8.0.0.156 2,867 12/5/2019
8.0.0.129 2,970 9/26/2019
7.0.0.126 4,054 6/10/2019
7.0.0.125 3,296 4/23/2019
7.0.0.124 3,352 3/2/2019
6.2.0.122 8,041 6/6/2018
6.1.0.120 3,581 5/7/2018
6.0.0.116 8,824 2/6/2018
6.0.0.113 3,546 11/26/2017
6.0.0.112 3,424 10/2/2017
6.0.0.111 1,557 10/2/2017
5.0.0.110 3,168 9/17/2017
4.1.0.106 1,637 3/12/2017
4.1.0.105 1,389 3/10/2017
4.1.0.104 1,379 3/9/2017
4.0.0.103 1,338 3/6/2017
4.0.0.101 1,396 2/27/2017
4.0.0.100 9,233 2/26/2017
3.0.0.88 3,575 2/21/2017
3.0.0.87 2,974 12/20/2016
3.0.0.85 2,857 10/22/2016
3.0.0.84 2,597 9/28/2016
3.0.0.80 2,441 8/15/2016
3.0.0.77 2,116 8/11/2016
3.0.0.75 2,331 8/2/2016
2.5.0.69 3,643 7/28/2016
2.5.0.64 4,049 4/19/2016
2.5.0.62 3,195 4/1/2016
2.5.0.61 3,311 3/9/2016
2.0.0.57 5,213 12/9/2015
2.0.0.56 3,248 11/12/2015
2.0.0.55 3,256 10/22/2015
2.0.0.53 3,306 8/18/2015
2.0.0.50 3,287 6/18/2015
2.0.0.44 5,225 4/9/2015
2.0.0.39 3,466 1/5/2015
2.0.0.38 3,552 12/17/2014
1.0.4 1,694 12/1/2014
1.0.3 1,659 11/25/2014
1.0.2 1,632 6/17/2014
1.0.1 1,536 6/17/2014
1.0.1-beta15 1,328 6/15/2014
1.0.0 9,582 6/12/2014
1.0.0-beta11 1,336 6/11/2014
1.0.0-alpha9 1,296 6/10/2014