Autofac.BindingByConvention 0.0.1

Manually registering types in an IoC container can be a tedious task. This extension to Autofac aims to help automatically registering types with common, built-in and extensible conventions.

There is a newer prerelease version of this package available.
See the version list below for details.
Install-Package Autofac.BindingByConvention -Version 0.0.1
dotnet add package Autofac.BindingByConvention --version 0.0.1
<PackageReference Include="Autofac.BindingByConvention" Version="0.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Autofac.BindingByConvention --version 0.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Autofac.BindingByConvention

master badge state develop badge state

Manually registering types in an IoC container can be a tedious task. This extension to Autofac aims to help automatically registering types with common, built-in and extensible conventions.

How to use it

Installation

Install with NuGet. Package is not published yet. At this time, just reference it the good old ugly way. (sorry!)

xcopy meh.

Usage and examples

The following example will create a new ContainerBuilder and

  • Register assembly types located in a list of assemblies by convention...
  • ... to the contracts (interfaces) that have...
  • ... a name matching a convention where the interface's type name has a leading I ...
  • ... except if this interface type is listed as a specified list of interfaces to ignore ...
  • ... and except if the contracts (interfaces) are marked with the NoBindingByConventionAttribute attribute...
  • ... Instances will be instanciated per-dependency (each resolved type is a different instance.)
var builder = new ContainerBuilder();

builder
    .RegisterAssemblyTypes(listOfAssemblies)
    .ByConvention().ToTheContractsWith()
        .NameMatching(InterfaceTypeName.HasLeadingI)
        .Except
            .Types(listOfInterfacesToIgnore)
        .Except
            .ContractsMarkedWith<NoBindingByConventionAttribute>()
        .Instanciated<PerDependency>();

Contribute

Build/Run

Build the project with dotnet standard 2

Autofac.BindingByConvention

master badge state develop badge state

Manually registering types in an IoC container can be a tedious task. This extension to Autofac aims to help automatically registering types with common, built-in and extensible conventions.

How to use it

Installation

Install with NuGet. Package is not published yet. At this time, just reference it the good old ugly way. (sorry!)

xcopy meh.

Usage and examples

The following example will create a new ContainerBuilder and

  • Register assembly types located in a list of assemblies by convention...
  • ... to the contracts (interfaces) that have...
  • ... a name matching a convention where the interface's type name has a leading I ...
  • ... except if this interface type is listed as a specified list of interfaces to ignore ...
  • ... and except if the contracts (interfaces) are marked with the NoBindingByConventionAttribute attribute...
  • ... Instances will be instanciated per-dependency (each resolved type is a different instance.)
var builder = new ContainerBuilder();

builder
    .RegisterAssemblyTypes(listOfAssemblies)
    .ByConvention().ToTheContractsWith()
        .NameMatching(InterfaceTypeName.HasLeadingI)
        .Except
            .Types(listOfInterfacesToIgnore)
        .Except
            .ContractsMarkedWith<NoBindingByConventionAttribute>()
        .Instanciated<PerDependency>();

Contribute

Build/Run

Build the project with dotnet standard 2

  • .NETStandard 2.0

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
0.0.5-beta02 194 7/17/2018
0.0.5-beta01 225 5/20/2018
0.0.3-beta02 211 3/28/2018
0.0.3-beta01 222 3/28/2018
0.0.2-beta03 208 3/27/2018
0.0.2-beta02 249 3/27/2018
0.0.2-beta01 191 3/27/2018
0.0.1 301 3/19/2018
0.0.1-beta01 207 3/27/2018
Show less