MikyM.Autofac.Extensions 1.1.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package MikyM.Autofac.Extensions --version 1.1.0                
NuGet\Install-Package MikyM.Autofac.Extensions -Version 1.1.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="MikyM.Autofac.Extensions" Version="1.1.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add MikyM.Autofac.Extensions --version 1.1.0                
#r "nuget: MikyM.Autofac.Extensions, 1.1.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 MikyM.Autofac.Extensions as a Cake Addin
#addin nuget:?package=MikyM.Autofac.Extensions&version=1.1.0

// Install MikyM.Autofac.Extensions as a Cake Tool
#tool nuget:?package=MikyM.Autofac.Extensions&version=1.1.0                

MikyM.Autofac.Extensions

Build Status

Library containing various extensions to Autofac but mainly ability to register services using attributes.

Features

Set of attributes allowing automatic registration:

  • [Service] - marks the class as an implementation of a service
  • [RegisterAs] - defines the service type to register, supports bare-bone types and Autofac's AsSelf() and AsImplementedInterfaces()
  • [Lifetime] - defines the lifetime with which the service should be registered
  • [EnableInterception] - enables interception on the service, in theory supports intercepting classes and interfaces (or both) (Intercept enum) though intercepting classes sometimes suffers from weird Castle.Core bugs thus when using interception it is encouraged to use interface service types
  • [InterceptedBy] - defines types that should intercept calls to the service
  • [FindConstructorsWith] - defines a constructor finder to use during creation of the service instance, supports only parameterless ctors and can't be used in conjunction with interceptors
  • [DecoratedBy] - defines types that decorate this service

Installation

Since the library utilizes Autofac, base Autofac configuration is required - Autofac's docs.

To pick up and register services via attributes use the extensions method on ContainerBuilder provided by the library:

builder.AddAttributeDefinedServices();

Example usage


public interface ICustomService
{

}

[Service]
[RegisterAs(typeof(ICustomService))]
[Lifetime(Lifetime.InstancePerLifetimeScope)]
[DecoratedBy(typeof(ISomeDecorator), 1)]
[EnableInterception(Intercept.Interface)]
[InterceptedBy(typeof(ISomeInterceptor))]
public class CustomService : ICustomService
{

}

Product Compatible and additional computed target framework versions.
.NET 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 was computed.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (4)

Showing the top 4 NuGet packages that depend on MikyM.Autofac.Extensions:

Package Downloads
MikyM.Common.DataAccessLayer

Base data access layer definitions.

MikyM.Common.EfCore.DataAccessLayer

Data access layer.

MikyM.CommandHandlers

Command handler pattern that does not hide dependancies like Mediator does.

MikyM.Common.MongoDb.DataAccessLayer

MongoDb data access layer.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.1.1 2,765 8/23/2022
1.1.0 391 8/22/2022
1.0.8 7,447 7/29/2022
1.0.7 7,064 6/10/2022
1.0.6 406 6/10/2022
1.0.5 16,115 3/18/2022
1.0.4 1,604 2/14/2022
1.0.3 681 2/14/2022
1.0.2 799 1/30/2022
1.0.1 430 1/30/2022
1.0.0 939 1/30/2022