AttributeBasedRegistration 2.0.4
See the version list below for details.
dotnet add package AttributeBasedRegistration --version 2.0.4
NuGet\Install-Package AttributeBasedRegistration -Version 2.0.4
<PackageReference Include="AttributeBasedRegistration" Version="2.0.4" />
paket add AttributeBasedRegistration --version 2.0.4
#r "nuget: AttributeBasedRegistration, 2.0.4"
// Install AttributeBasedRegistration as a Cake Addin #addin nuget:?package=AttributeBasedRegistration&version=2.0.4 // Install AttributeBasedRegistration as a Cake Tool #tool nuget:?package=AttributeBasedRegistration&version=2.0.4
AttributeBasedRegistration
Library allowing registering services with Autofac and Microsoft's DI container via attributes. Additionally contains various extensions to Autofac and Microsoft's DI container.
Features
Set of attributes allowing automatic registration:
- [ServiceImplementation] - marks the class as an implementation of a service, allows for a quick definition providing a few possible ctors
- [RegisterAs] - explicitly defines service types or a registration strategy
- [Lifetime] - explicitly defines the lifetime with which the service should be registered (Autofac's based - Microsoft's DI equivalent will be used) - some supported only with Autofac
- [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 - supported only with Autofac
- [InterceptedBy] - defines interceptor types that should intercept calls to the service - supported only with Autofac
- [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 - supported only with Autofac
- [DecoratedBy] - defines types that decorate this service - supported only with Autofac
The usage of the Lifetime
attribute versus supplying the lifetime to the ServiceImplementation
is per users taste, the data from the more specific attribute will take precedence.
Similar to the above, using multiple RegisterAs
or InterceptedBy
attributes versus one and supplying multiple types is per users taste - types will be aggregated from all attributes.
Installation
To pick up and register services via attributes use the extensions method on ContainerBuilder
or IServiceCollection
provided by the library:
builder.AddAttributeDefinedServices(assembliesToScan);
Example usage
public interface ICustomService1
{
}
[ServiceImplementation]
[RegisterAs(typeof(ICustomService))]
[Lifetime(ServiceLifetime.InstancePerLifetimeScope)]
[DecoratedBy(1, typeof(ISomeDecorator))]
[EnableInterception(InterceptionStrategy.Interface)]
[InterceptedBy(1, typeof(ISomeInterceptor))]
public class CustomService1 : ICustomService1
{
}
public interface ICustomService2
{
}
[ServiceImplementation(ServiceLifetime.SingleInstance, RegistrationStrategy.AsConventionNamedInterface)]
public class CustomService2 : ICustomService2
{
}
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 is compatible. 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.5.0)
- Autofac.Extensions.DependencyInjection (>= 8.0.0)
- Autofac.Extras.DynamicProxy (>= 6.0.1)
- Castle.Core.AsyncInterceptor (>= 2.1.0)
- JetBrains.Annotations (>= 2022.3.1)
- Microsoft.Extensions.Hosting.Abstractions (>= 7.0.0)
- Microsoft.Extensions.Logging (>= 7.0.0)
- MikyM.Utilities (>= 2.0.1)
-
net7.0
- Autofac (>= 6.5.0)
- Autofac.Extensions.DependencyInjection (>= 8.0.0)
- Autofac.Extras.DynamicProxy (>= 6.0.1)
- Castle.Core.AsyncInterceptor (>= 2.1.0)
- JetBrains.Annotations (>= 2022.3.1)
- Microsoft.Extensions.Hosting.Abstractions (>= 7.0.0)
- Microsoft.Extensions.Logging (>= 7.0.0)
- MikyM.Utilities (>= 2.0.1)
NuGet packages (5)
Showing the top 5 NuGet packages that depend on AttributeBasedRegistration:
Package | Downloads |
---|---|
DataExplorer
Library featuring an opinionated, reusable data access layer offering abstractions and implementations for SQL storages (EF Core). |
|
ResultCommander
Library featuring a command handler pattern. |
|
AttributeBasedRegistration.Autofac
Extensions to Autofac DI mainly allowing registration of services via attributes amongst other minor things. |
|
ResultCQRS
Library featuring CQRS pattern. |
|
DataExplorer.Unstable
Library featuring common patterns in regard to working with data storages. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
2.2.7 | 1,316 | 7/23/2024 |
2.2.6 | 2,258 | 1/24/2024 |
2.2.5 | 235 | 1/22/2024 |
2.2.4 | 118 | 1/22/2024 |
2.2.3 | 584 | 11/22/2023 |
2.2.2 | 549 | 11/20/2023 |
2.2.1 | 144 | 11/20/2023 |
2.2.0 | 211 | 11/20/2023 |
2.1.3 | 1,512 | 8/18/2023 |
2.1.2 | 934 | 7/10/2023 |
2.1.1 | 1,634 | 4/3/2023 |
2.1.0 | 1,346 | 3/14/2023 |
2.0.10 | 4,204 | 1/9/2023 |
2.0.9 | 1,180 | 12/22/2022 |
2.0.8 | 430 | 12/22/2022 |
2.0.7 | 310 | 12/22/2022 |
2.0.6 | 1,156 | 11/21/2022 |
2.0.5 | 1,399 | 11/19/2022 |
2.0.4 | 903 | 11/19/2022 |
2.0.3 | 598 | 11/19/2022 |
2.0.2 | 299 | 11/19/2022 |
2.0.1 | 425 | 11/19/2022 |
2.0.0 | 315 | 11/19/2022 |
1.2.15 | 1,557 | 9/27/2022 |
1.2.14 | 412 | 9/27/2022 |
1.2.13 | 397 | 9/27/2022 |
1.2.12 | 1,260 | 9/26/2022 |
1.2.11 | 439 | 9/26/2022 |
1.2.10 | 1,143 | 9/24/2022 |
1.2.9 | 774 | 9/24/2022 |
1.2.8 | 663 | 9/24/2022 |
1.2.7 | 394 | 9/24/2022 |
1.2.6 | 650 | 9/24/2022 |
1.2.5 | 426 | 9/24/2022 |
1.2.4 | 420 | 9/24/2022 |
1.2.3 | 448 | 9/24/2022 |
1.2.2 | 503 | 9/24/2022 |
1.2.1 | 422 | 9/24/2022 |
1.2.0 | 425 | 9/24/2022 |
1.1.16 | 436 | 9/24/2022 |
1.1.15 | 417 | 9/24/2022 |
1.1.14 | 420 | 9/24/2022 |
1.1.13 | 420 | 9/24/2022 |
1.1.12 | 423 | 9/24/2022 |
1.1.11 | 409 | 9/24/2022 |
1.1.10 | 1,655 | 9/19/2022 |
1.1.9 | 1,221 | 9/19/2022 |
1.1.8 | 1,143 | 9/19/2022 |
1.1.7 | 450 | 9/19/2022 |
1.1.6 | 1,107 | 9/19/2022 |
1.1.5 | 427 | 9/19/2022 |
1.1.4 | 430 | 9/19/2022 |
1.1.3 | 418 | 9/19/2022 |
1.1.2 | 435 | 9/19/2022 |
1.1.1 | 401 | 9/17/2022 |
1.1.0 | 417 | 9/17/2022 |
1.0.0 | 7,075 | 8/24/2022 |