AttributeDecorator 1.0.0
dotnet add package AttributeDecorator --version 1.0.0
NuGet\Install-Package AttributeDecorator -Version 1.0.0
<PackageReference Include="AttributeDecorator" Version="1.0.0" />
paket add AttributeDecorator --version 1.0.0
#r "nuget: AttributeDecorator, 1.0.0"
// Install AttributeDecorator as a Cake Addin #addin nuget:?package=AttributeDecorator&version=1.0.0 // Install AttributeDecorator as a Cake Tool #tool nuget:?package=AttributeDecorator&version=1.0.0
This package allows you to define decorators as attributes on handler classes in order to wire up your decorated implementations of an interface.
Instead of manually declaring how each service is ordered
serviceProvider.AddTransient<IDummyService>(x =>
new RetryDecorator(
new AdditionDecorator(
new DoubleResultDecorator(
new DummyService())), x.GetService<AppConfiguration>()));
Use attributes on the handler to declare the order in which the services are executed.
[RetryDecorator]
[AdditionDecorator]
[DoubleResultDecorator]
public class DummyService : IDummyService
and add in the ConfigureService method
serviceProvider.AddDecoratedService<DummyService>(ServiceLifetime.Transient);
To get started create a decorated service in the normal way then create an attribute with same name as the decorator with "Attribute" appended to the end.
public class RetryDecoratorAttribute : Attribute
{
}
public class RetryDecorator : IDummyService
Then add the attribute to the handler class
[RetryDecorator]
public class DummyService : IDummyService
and add the handler to the service provider
serviceProvider.AddDecoratedService<DummyService>(ServiceLifetime.Transient);
See the example project or feel free to message me for more details.
https://dev.azure.com/alexricketts10/_git/AttributeDecorator
Inspired by Vladimir Khorikov course CQRS in Practice.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. 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. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Microsoft.Extensions.DependencyInjection (>= 2.2.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.0.0 | 649 | 5/4/2019 |