Skip to content
This repository has been archived by the owner on Jan 4, 2025. It is now read-only.

cofoundry-cms/Cofoundry.Plugins.DependencyInjection.Autofac

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cofoundry.Plugins.DependencyInjection.Autofac

Build status NuGet Gitter

This library is a plugin for Cofoundry. For more information on getting started with Cofoundry check out the Cofoundry repository.

Overview

Autofac is an addictive Inversion of Control container for .NET Core, ASP.NET Core, .NET 4.5.1+, Universal Windows apps, and more.

autofac.org

This library is an Autofac implementation of the Cofoundry DI system.

Bootstrapping In a Website

The Cofoundry.Plugins.DependencyInjection.AutoFac.Web can be used to bootstrap your web application, which provides the following:

  • Registers all Cofoundry and auto-registered dependencies
  • Registers the MVC, WebApi and the common service locators
  • Registers all MVC & WebApi controllers

Registration must be done before Cofoundry is initialized, i.e.

using Microsoft.Owin;
using Owin;
using Cofoundry.Plugins.DependencyInjection.AutoFac.Web;
using Cofoundry.Web;

[assembly: OwinStartup(typeof(MySite.Startup))]

namespace MySite 
{
    public class Startup
    {
        public void Configuration(IAppBuilder app)
        {
            app.UseCofoundryAutoFacIntegration();
            app.UseCofoundry();
        }
    } 
}

Bootstrapping Manually

Outside of a web scenario, you can configure your Autofac container manually and add Cofoundry registrations using the AutoFacContainerBuilder

using AutoFac;
using Cofoundry.Plugins.DependencyInjection.AutoFac;

var autoFacBuilder = new ContainerBuilder();
var cofoundryBuilder = new AutoFacContainerBuilder(autoFacBuilder);

cofoundryBuilder.Build();

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published