Pattern 2.5.2
See the version list below for details.
dotnet add package Pattern --version 2.5.2
NuGet\Install-Package Pattern -Version 2.5.2
<PackageReference Include="Pattern" Version="2.5.2" />
<PackageVersion Include="Pattern" Version="2.5.2" />
<PackageReference Include="Pattern" />
paket add Pattern --version 2.5.2
#r "nuget: Pattern, 2.5.2"
#:package Pattern@2.5.2
#addin nuget:?package=Pattern&version=2.5.2
#tool nuget:?package=Pattern&version=2.5.2
Introduction
This package aims to facilitate the inclusion of design patterns applied to the Asp.net Core, integrating concepts of AOP (DynamicProxy).
Implemented patterns: Strategy
pattern
Patterns aplicados ao asp.net core.
AOP Pattern
Instructions
1 - Create Custom intercept attribute inheriting from InterceptorAttribute
public class TestInterceptorAttribute : InterceptorAttribute
{
protected override async Task<TResult> HandleInterceptAsync<TResult>(IInvocation invocation, Func<Task<TResult>> result)
{
return await result();
}
}
2 - Include attribute annotation above the method that needs to be intercepted
public interface ITestService
{
void Teste1();
void Teste2();
}
public class TestService : ITestService
{
[TestInterceptor]
public void Teste1()
{
}
public void Teste2()
{
}
}
3 - Include in ServiceCollection with DependencyIncection with true parameter
services.AddScoppedStrategy<ITestService, TestService>(true);
Or with a different life cycle, according to your need.
Strategy Pattern
Instructions
1 - Include the following code without Startup.cs, as it will not work in its entirety without it.
//Logic implemented according to your code
services.AddSingletonStrategy<IStrategy<Request, Response>, RequestStrategy>();
//OR
services.AddScoppedStrategy<IStrategy<Request, Response>, RequestStrategy>();
//OR
services.services.AddTransientStrategy<IStrategy<Request, Response>, RequestStrategy>();
2 - Implementing the class:
public class RequestStrategy : IStrategy<Request, Response>
public RequestStrategy(...)
{
...
}
public async Task<Response> HandleAsync(Request request, CancellationToken cancellationToken)
{
return new Response();
}
If you want to implement using the annotation for interceptor, include the annotation of interceptor in the method according to the code below:
[Validator(typeof(TestStrategyRequestValidator))]
public async Task<Response> HandleAsync(Request request, CancellationToken cancellationToken)
{
return new Response();
}
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. 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. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.1 is compatible. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | 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.1
- Castle.Core (>= 5.1.0)
- Castle.Core.AsyncInterceptor (>= 2.1.0)
- Microsoft.Extensions.DependencyInjection (>= 7.0.0)
-
net6.0
- Castle.Core (>= 5.1.0)
- Castle.Core.AsyncInterceptor (>= 2.1.0)
- Microsoft.Extensions.DependencyInjection (>= 7.0.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 |
|---|---|---|
| 3.0.0 | 2,074 | 4/3/2025 |
| 2.5.2 | 3,369 | 1/12/2023 |
| 2.5.1 | 999 | 1/11/2023 |
| 2.5.0 | 401 | 12/20/2022 |
| 2.4.0 | 982 | 8/9/2022 |
| 2.3.0 | 552 | 8/3/2022 |
| 2.2.0 | 612 | 7/4/2022 |
| 2.1.1 | 527 | 6/30/2022 |
| 2.1.0 | 603 | 4/20/2022 |
| 2.0.0 | 553 | 4/20/2022 |
| 1.0.1 | 613 | 3/3/2022 |
| 1.0.0 | 558 | 3/3/2022 |
| 0.5.5 | 655 | 2/14/2022 |
| 0.5.4 | 568 | 2/14/2022 |
| 0.5.3 | 555 | 2/14/2022 |
| 0.5.2 | 560 | 2/10/2022 |
| 0.5.1 | 579 | 2/10/2022 |
| 0.5.0 | 589 | 2/10/2022 |
| 0.4.0 | 580 | 2/10/2022 |
| 0.3.2 | 574 | 2/10/2022 |