MikyM.Autofac.Extensions
1.1.0
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
<PackageReference Include="MikyM.Autofac.Extensions" Version="1.1.0" />
paket add MikyM.Autofac.Extensions --version 1.1.0
#r "nuget: MikyM.Autofac.Extensions, 1.1.0"
// 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
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()
andAsImplementedInterfaces()
- [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 | Versions 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. |
-
net6.0
- Autofac (>= 6.4.0)
- Autofac.Extensions.DependencyInjection (>= 8.0.0)
- Autofac.Extras.DynamicProxy (>= 6.0.1)
- Castle.Core.AsyncInterceptor (>= 2.1.0)
- JetBrains.Annotations (>= 2022.1.0)
- Microsoft.Extensions.Logging (>= 6.0.0)
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.