All Projects → henkmollema → StartupModules

henkmollema / StartupModules

Licence: MIT license
Startup modules for ASP.NET Core.

Programming Languages

C#
18002 projects

Projects that are alternatives of or similar to StartupModules

Lucifer
A Powerful Penetration Tool For Automating Penetration Tasks Such As Local Privilege Escalation, Enumeration, Exfiltration and More... Use Or Build Automation Modules To Speed Up Your Cyber Security Life
Stars: ✭ 302 (+815.15%)
Mutual labels:  modular, modules
Simplcommerce
A simple, cross platform, modularized ecommerce system built on .NET Core
Stars: ✭ 3,474 (+10427.27%)
Mutual labels:  modular, aspnetcore
lamp-luwak
Service-oriented state management for React
Stars: ✭ 12 (-63.64%)
Mutual labels:  modular, dependency-injection
Registry
Components as records of functions for Haskell
Stars: ✭ 132 (+300%)
Mutual labels:  modules, dependency-injection
Zikrouter
Interface-oriented router for discovering modules, and injecting dependencies with protocol in Objective-C and Swift.
Stars: ✭ 516 (+1463.64%)
Mutual labels:  modular, dependency-injection
Android Clean Architecture
Showcasing a Clean Architecture approach from our Android applications framework!
Stars: ✭ 160 (+384.85%)
Mutual labels:  modules, dependency-injection
Jdk9 Jigsaw
Examples and exercises based on some of the features of jigsaw in JDK9/Jigsaw (Early Access builds)
Stars: ✭ 275 (+733.33%)
Mutual labels:  modular, modules
KickStart
Application initialization helper
Stars: ✭ 42 (+27.27%)
Mutual labels:  dependency-injection, startup
Mastering Modular Javascript
📦 Module thinking, principles, design patterns and best practices.
Stars: ✭ 3,972 (+11936.36%)
Mutual labels:  modular, modules
Module Shop
一个基于 .NET Core构建的简单、跨平台、模块化的商城系统
Stars: ✭ 398 (+1106.06%)
Mutual labels:  modular, aspnetcore
Depject
simplest dependency injection
Stars: ✭ 90 (+172.73%)
Mutual labels:  modules, dependency-injection
Netcorecms
NetCoreCMS is a modular theme supported Content Management System developed using ASP.Net Core 2.0 MVC. Which is also usable as web application framework. This project is still under development. Please do not use before it's first release.
Stars: ✭ 165 (+400%)
Mutual labels:  modular, aspnetcore
Graphql Modules
Enterprise Grade Tooling For Your GraphQL Server
Stars: ✭ 962 (+2815.15%)
Mutual labels:  modules, dependency-injection
CodeIgniter-HMVC
CodeIgniter 3.1.10 with Modular Extensions - HMVC and Whoops Error Handling Framework 2.5.0
Stars: ✭ 30 (-9.09%)
Mutual labels:  modular, modules
Inyector
Library to Implement Automatic dependency injection by Configuration over Scaned Assemblies
Stars: ✭ 13 (-60.61%)
Mutual labels:  aspnetcore, dependency-injection
mindjs
Minimalistic, pure Node.js framework superpowered with Dependency Injection 💡 💻 🚀
Stars: ✭ 17 (-48.48%)
Mutual labels:  modular, dependency-injection
Pext
Python-based extendable tool
Stars: ✭ 380 (+1051.52%)
Mutual labels:  modular, modules
Module Shop Mini Program
一个基于 .NET Core构建的简单、跨平台、模块化的商城系统
Stars: ✭ 89 (+169.7%)
Mutual labels:  modular, aspnetcore
L5modular
Generates and handles Modules for Laravel
Stars: ✭ 188 (+469.7%)
Mutual labels:  modular, modules
ideas-for-projects-people-would-use
Every time I have an idea, I write it down. These are a collection of my top software ideas -- problems I think enough people have that don't have solutions. I expect you can reach a decent userbase if marketed correctly, as I am surely not the only one with these problems.
Stars: ✭ 646 (+1857.58%)
Mutual labels:  startup

Startup Modules

Startup modules for ASP.NET Core.

Create modular and focused Startup-like classes for each of your application's features/components/modules and keep your startup file sane.

Windows Linux NuGet
Windows Linux NuGet

Installation

StartupModules is available on NuGet

Getting started

Create a startup module

Creating a startup module is easy. Create a new class and implement the IStartupModule interface:

public class MyStartupModule : IStartupModule
{
    public void ConfigureServices(IServiceCollection services, ConfigureServicesContext context)
    {
    }

    public void Configure(IApplicationBuilder app, ConfigureMiddlewareContext context)
    {
    }
}

You'll notice the familiair ConfigureServices and Configure methods. A convient context-object is passed to both of them providing useful services while configuring your application, such as IHostingEnvironment and IConfiguration. A scoped IServiceProvider is present in the ConfigureMiddlewareContext as well.

Configure startup modules

You can configure startup modules using the UseStartupModules when building the web host in Program.cs:

public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
    WebHost.CreateDefaultBuilder(args)
        .UseStartupModules()
        .UseStartup<Startup>();

This will automatically discover startup modules (and application initializers) in the entry assembly of your application. You can also specify an array of assemblies to discover startup modules from:

.UseStartupModules(typeof(Startup).Assembly, typeof(SomeTypeInAnotherAssembly).Assembly)

You can have more control of the configuration using the overload with the options:

.UseStartupModules(options =>
{
    // Discover from entry assembly
    o.DiscoverStartupModules();

    // Discover from specific assemblies
    o.DiscoverStartupModules(typeof(Startup).Assembly, typeof(SomeTypeInAnotherAssembly).Assembly);

    // Add individual startup modules
    o.AddStartupModule<MyStartupModule>();
})

Application Initializers

Application initializers allow you to write asynchronous startup logic for your application, such as configuring your Entity Framework database context and executing migrations. Applications initializers are, just like startup modules, discovered automatically as well.

public class DatabaseInitializer : IApplicationInitializer
{
    private readonly AppDbContext _dbContext;

    public DatabaseInitializer(AppDbContext dbContext)
    {
        _dbContext = dbContext;
    }

    public async Task Task Invoke()
    {
        await _dbContext.MigrateAsync();
    }
}

You can specify any number of dependencies available in your application via the constructor of an application initializer. The dependencies will be resolved from a scoped service provider instance and will be disposed after application startup. This prevents common pitfalls such as a resolving a singleton database context and leaking its connection for the lifetime off the application and avoids the hassle of creating a service provider scope yourself.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].