{"id":22882362,"url":"https://github.com/loresoft/kickstart","last_synced_at":"2025-04-04T08:04:47.610Z","repository":{"id":17459162,"uuid":"20233150","full_name":"loresoft/KickStart","owner":"loresoft","description":"Application initialization helper","archived":false,"fork":false,"pushed_at":"2024-10-07T13:52:57.000Z","size":4063,"stargazers_count":42,"open_issues_count":4,"forks_count":12,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-04-03T11:15:15.834Z","etag":null,"topics":["autofac","automapper","c-sharp","container-registration","dependency-injection","ioc-container","registered-services","simpleinjector","startup"],"latest_commit_sha":null,"homepage":"http://loresoft.com/KickStart/","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/loresoft.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"loresoft"}},"created_at":"2014-05-27T19:46:15.000Z","updated_at":"2024-10-07T13:53:01.000Z","dependencies_parsed_at":"2024-06-06T06:19:22.636Z","dependency_job_id":"368a9b86-303c-4ed7-96ad-7326a9d36095","html_url":"https://github.com/loresoft/KickStart","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loresoft%2FKickStart","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loresoft%2FKickStart/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loresoft%2FKickStart/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loresoft%2FKickStart/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/loresoft","download_url":"https://codeload.github.com/loresoft/KickStart/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247142062,"owners_count":20890652,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["autofac","automapper","c-sharp","container-registration","dependency-injection","ioc-container","registered-services","simpleinjector","startup"],"created_at":"2024-12-13T18:17:08.961Z","updated_at":"2025-04-04T08:04:47.590Z","avatar_url":"https://github.com/loresoft.png","language":"C#","readme":"# KickStart\n\nApplication start-up helper to initialize things like an IoC container, register mapping information or run a task.\n\n[![Build status](https://github.com/loresoft/KickStart/workflows/Build/badge.svg)](https://github.com/loresoft/KickStart/actions)\n\n[![Coverage Status](https://coveralls.io/repos/github/loresoft/KickStart/badge.svg?branch=master)](https://coveralls.io/github/loresoft/KickStart?branch=master)   \n\n| Package | Version |\n| :--- | :--- |\n| [KickStart](https://www.nuget.org/packages/KickStart/) |  [![KickStart](https://img.shields.io/nuget/v/KickStart.svg)](https://www.nuget.org/packages/KickStart/) |\n| [KickStart.Autofac](https://www.nuget.org/packages/KickStart.Autofac/) |  [![KickStart.Autofac](https://img.shields.io/nuget/v/KickStart.Autofac.svg)](https://www.nuget.org/packages/KickStart.Autofac/) |\n| [KickStart.AutoMapper](https://www.nuget.org/packages/KickStart.AutoMapper/) |  [![KickStart.AutoMapper](https://img.shields.io/nuget/v/KickStart.AutoMapper.svg)](https://www.nuget.org/packages/KickStart.AutoMapper/) |\n| [KickStart.DependencyInjection](https://www.nuget.org/packages/KickStart.DependencyInjection/) |  [![KickStart.DependencyInjection](https://img.shields.io/nuget/v/KickStart.DependencyInjection.svg)](https://www.nuget.org/packages/KickStart.DependencyInjection/) |\n| [KickStart.MongoDB](https://www.nuget.org/packages/KickStart.MongoDB/) |  [![KickStart.MongoDB](https://img.shields.io/nuget/v/KickStart.MongoDB.svg)](https://www.nuget.org/packages/KickStart.MongoDB/) |\n| [KickStart.Ninject](https://www.nuget.org/packages/KickStart.Ninject/) |  [![KickStart.Ninject](https://img.shields.io/nuget/v/KickStart.Ninject.svg)](https://www.nuget.org/packages/KickStart.Ninject/) |\n| [KickStart.SimpleInjector](https://www.nuget.org/packages/KickStart.SimpleInjector/) |  [![KickStart.SimpleInjector](https://img.shields.io/nuget/v/KickStart.SimpleInjector.svg)](https://www.nuget.org/packages/KickStart.SimpleInjector/) |\n| [KickStart.Unity](https://www.nuget.org/packages/KickStart.Unity/) |  [![KickStart.Unity](https://img.shields.io/nuget/v/KickStart.Unity.svg)](https://www.nuget.org/packages/KickStart.Unity/) |\n\n## Download\n\nThe KickStart library is available on nuget.org via package name `KickStart`.\n\nTo install KickStart, run the following command in the Package Manager Console\n\n    PM\u003e Install-Package KickStart\n\nMore information about NuGet package available at\n\u003chttps://nuget.org/packages/KickStart\u003e\n\n## Development Builds\n\nDevelopment 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. \n\nIn your Package Manager settings add the following package source for development builds:\n\u003chttps://f.feedz.io/loresoft/open/nuget/index.json\u003e\n\n## Features\n\n- Run tasks on application start-up\n- Extension model to add library specific start up tasks\n- Common IoC container adaptor based on `IServiceProvider`\n- Singleton instance of an application level IoC container `Kick.ServiceProvider`\n\n\n## Example\n\nThis 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. \n\n```csharp\nKick.Start(config =\u003e config\n    .IncludeAssemblyFor\u003cUserModule\u003e()\n    .UseAutofac()\n    .UseAutoMapper()\n    .UseStartupTask()\n);\n```\n\nPass data to the startup modules\n\n```csharp\nKick.Start(config =\u003e config\n    .Data(\"environment\", \"debug\")\n    .Data(d =\u003e\n    {\n        d[\"key\"] = 123;\n        d[\"server\"] = \"master\";\n    })\n);\n```\n\n## Extensions\n\n- StartupTask - Run any class that implements `IStartupTask`\n- Autofac - Registers all Autofac `Module` classes and creates the container\n- AutoMapper - Registers all AutoMapper `Profile` classes\n- DependencyInjection - Register all `IDependencyInjectionRegistration` instances for Microsoft.Extensions.DependencyInjection\n- MongoDB - Registers all `BsonClassMap` classes with MongoDB serialization\n- Ninject - Registers all `NinjectModule` classes and creates an `IKernal`\n- SimpleInjector - Run all `ISimpleInjectorRegistration` instances allowing container registration\n- Unity - Run all `IUnityRegistration` instances allowing container registration\n\n### StartupTask\n\nThe 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.\n\n\nBasic usage\n\n```csharp\nKick.Start(config =\u003e config\n    .IncludeAssemblyFor\u003cUserModule\u003e() // where to look for tasks\n    .UseStartupTask() // include startup tasks in the Kick Start\n);\n```\n\nRun a delegate on startup\n\n```csharp\nKick.Start(config =\u003e config\n    .IncludeAssemblyFor\u003cUserModule\u003e()\n    .UseAutofac() // init Autofac or any other IoC as container\n    .UseStartupTask(c =\u003e c =\u003e\n    {\n        c.Run((services, data) =\u003e\n        {\n            //do work here\n        });\n    })\n);\n```\n\n### Autofac\n\nThe 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.\n\nBasic usage\n\n```csharp\nKick.Start(config =\u003e config\n    .IncludeAssemblyFor\u003cUserRepository\u003e() // where to look for tasks\n    .UseAutofac() // initialize Autofac\n);\n```\n\nUse with ASP.NET MVC\n\n```csharp\nKick.Start(c =\u003e c\n    .IncludeAssemblyFor\u003cUserModule\u003e()\n    .UseAutofac(a =\u003e a\n        .Initialize(b =\u003e b.RegisterControllers(typeof(MvcApplication).Assembly)) // register all controllers \n        .Container(r =\u003e DependencyResolver.SetResolver(new AutofacDependencyResolver(r))) // set asp.net resolver\n    )\n    .UseAutoMapper()\n    .UseMongoDB()\n    .UseStartupTask()\n);\n```\n\n\nTo install Autofac extension, run the following command in the Package Manager Console\n\n    PM\u003e Install-Package KickStart.Autofac\n\n### DependencyInjection\n\nThe DependencyInjection extension allows using Microsoft.Extensions.DependencyInjection for depenancy injection.\n\nBasic Usage\n\n```csharp\nKick.Start(config =\u003e config\n    .LogTo(_output.WriteLine)\n    .IncludeAssemblyFor\u003cUserRepository\u003e() // where to look\n    .UseDependencyInjection() // initialize DependencyInjection\n);\n```\n\nIntegrate with asp.net core 2.0\n\n```csharp\npublic class Startup\n{\n    public Startup(IConfiguration configuration)\n    {\n        Configuration = configuration;\n    }\n\n    public IConfiguration Configuration { get; }\n\n    // This method gets called by the runtime. Use this method to add services to the container.\n    public void ConfigureServices(IServiceCollection services)\n    {\n        // this will auto register logging and run the DependencyInjection startup\n        services.KickStart(c =\u003e c\n            .IncludeAssemblyFor\u003cUserRepository\u003e() // where to look\n            .Data(\"configuration\", Configuration) // pass configuration to all startup modules\n            .Data(\"hostProcess\", \"web\") // used for conditional registration\n            .UseStartupTask() // run startup task\n        );\n    }\n}\n```\n\nTo install DependencyInjection extension, run the following command in the Package Manager Console\n\n    PM\u003e Install-Package KickStart.DependencyInjection\n\n### SimpleInjector\n\nThe 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.\n\nBasic usage\n\n```csharp\nKick.Start(config =\u003e config\n    .IncludeAssemblyFor\u003cUserRepository\u003e() // where to look\n    .UseSimpleInjector () // initialize SimpleInjector\n);\n```\n\nUsing SimpleInjector with ASP.NET WebAPI\n\n```csharp\nKick.Start(c =\u003e c\n    .LogTo(_logger.Debug)\n    .IncludeAssemblyFor\u003cUserModule\u003e()\n    .Data(\"hostProcess\", \"web\")\n    .UseSimpleInjector(s =\u003e s\n        .Verify(VerificationOption.VerifyOnly)\n        .Initialize(container =\u003e\n        {\n            container.Options.DefaultScopedLifestyle = new WebApiRequestLifestyle();\n            container.RegisterWebApiControllers(httpConfiguration); // register all controllers\n        })\n        .Container(container =\u003e\n        {\n            httpConfiguration.DependencyResolver = new SimpleInjectorWebApiDependencyResolver(container); // set asp.net resolver\n        })\n    )\n    .UseStartupTask()\n);\n```\n\nTo install SimpleInjector extension, run the following command in the Package Manager Console\n\n    PM\u003e Install-Package KickStart.SimpleInjector\n\n### Unity\n\nThe 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.\n\nBasic usage\n\n```csharp\nKick.Start(config =\u003e config\n    .IncludeAssemblyFor\u003cUserRepository\u003e() // where to look\n    .UseUnity () // initialize Unity\n);\n```\n\nTo install Unity extension, run the following command in the Package Manager Console\n\n    PM\u003e Install-Package KickStart.Unity\n\n\n### xUnit\n\nExample of bootstraping and logging with xUnit tests.\n\n```csharp\npublic class StartupTaskStarterTest\n{\n    private readonly ITestOutputHelper _output;\n\n    public StartupTaskStarterTest(ITestOutputHelper output)\n    {\n        _output = output;\n\n        // bootstrap project\n        Kick.Start(config =\u003e config\n            .LogTo(_output.WriteLine)\n            .Data(\"environment\", \"test\") // pass data for conditional registration\n            .IncludeAssemblyFor\u003cUserRepository\u003e()\n            .UseSimpleInjector () // initialize SimpleInjector\n            .UseStartupTask()\n        );\n\n    }\n\n    [Fact]\n    public void RunTest()\n    {\n        var userRepository = Kick.ServiceProvider.GetService\u003cIUserRepository\u003e();\n        Assert.NotNull(userRepository);\n\n        // more tests\n    }\n}\n```\n\n## Generic Service Registration\n\nKickStart 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.\n\nExample module to register services\n\n```csharp\npublic class UserServiceModule : IServiceModule\n{\n    public void Register(IServiceRegistration services, IDictionary\u003cstring, object\u003e data)\n    {\n        services.RegisterSingleton\u003cIConnection, SampleConnection\u003e();\n        services.RegisterTransient\u003cIUserService, UserService\u003e(c =\u003e new UserService(c.GetService\u003cIConnection\u003e()));\n\n        // register all types that are assignable to IService\n        services.RegisterSingleton(r =\u003e r\n            .Types(t =\u003e t.AssignableTo\u003cIService\u003e())\n            .As(s =\u003e s.Self().ImplementedInterfaces())\n        );\n\n        // register all types that are assignable to IVehicle\n        services.RegisterSingleton(r =\u003e r\n            .Types(t =\u003e t.AssignableTo\u003cIVehicle\u003e())\n            .As(s =\u003e s.Self().ImplementedInterfaces())\n        );\n    }\n}\n```\n\n## Change Log\n\n### Version 7.0\n\n- drop net45 and netstandard1.5 support\n\n### Version 6.0\n\n- add assembly scanning for generic service registration\n- [Breaking] internal change to `Context`.  Property Assemblies changed to Types.\n\n### Version 5.0\n\n- update to .net core 2\n\n### Version 4.0\n\n- [Breaking] Removed `IContainerAdaptor` and changed to use `IServiceProvider` instead\n- [Breaking] Renamed `Kick.Container` to `Kick.ServiceProvider`\n- [Breaking] Removed logging abstractions.  Logging is now a simple `Action\u003cstring\u003e` delegate\n- [Breaking] changed object creation to use ServiceProvider by default\n- [Breaking] changed `IStartupTask.Run` to `IStartupTask.RunAsync` \n- changed startup tasks that run async and in parallel by Priority\n- added shared data dictionary that is passed to all startup modules\n- added delegate based startup action\n- added `IServiceModule` and `IServiceRegistration` to abstract service/container registration\n","funding_links":["https://github.com/sponsors/loresoft"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Floresoft%2Fkickstart","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Floresoft%2Fkickstart","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Floresoft%2Fkickstart/lists"}