NexusAOP 1.0.0
See the version list below for details.
dotnet add package NexusAOP --version 1.0.0
NuGet\Install-Package NexusAOP -Version 1.0.0
<PackageReference Include="NexusAOP" Version="1.0.0" />
paket add NexusAOP --version 1.0.0
#r "nuget: NexusAOP, 1.0.0"
// Install NexusAOP as a Cake Addin #addin nuget:?package=NexusAOP&version=1.0.0 // Install NexusAOP as a Cake Tool #tool nuget:?package=NexusAOP&version=1.0.0
<div align="center" style="text-align: center">
</div> <div align="center" style="text-align: center" > <h3 align="center">NexusAop</h3>
<p style="text-align: center"> <b>NexusAop</b> is a powerful and flexible library for reflection and aspect-oriented programming (AOP) in .NET 5.0. This library enables developers to easily apply cross-cutting concerns to their applications by utilizing custom attributes. With NexusAop, you can interrupt method executions, perform specific actions, and retrieve results seamlessly.
<br /> <a href="https://github.com/adessoTurkey-dotNET/NexusAop/issues">Report Bug or Request Feature</a> · <a href="mailto:asli.yigit@adesso.com.tr?subject=NexusAop">Contect Me Via Mail</a> · <a href="https://www.linkedin.com/in/asl%C4%B1-yi%C4%9Fit-b9b78911b/">Contect Me Via Linkedin</a> </p> </div> </div>
Table Of Content
Features
- <b>Aspect-Oriented Programming (AOP):</b> <br /> NexusAop empowers developers to embrace the principles of AOP by providing a straightforward mechanism for applying cross-cutting concerns using custom attributes.
- <b>Method Interruption:</b> <br /> Leverage the NextAsync() method to interrupt the execution of a method and perform specific actions before allowing the method to continue. This allows for dynamic and context-aware behavior in your applications.
- <b>Result Retrieval:</b> <br /> Utilize the ExecuteAndGetResultAsync() method to retrieve the result of the related method. This feature is particularly useful when you need to capture and manipulate the output of a method in a controlled manner.
- <b>Custom Attributes:</b> <br /> Easily create and apply custom attributes to your methods, enabling a clean and declarative way to define aspects. Custom attributes in NexusAop serve as the building blocks for weaving cross-cutting concerns into your application.
- <b>.NET 5.0 Compatibility:</b> <br /> NexusAop is designed to seamlessly integrate with .NET 5.0.
Get It Started
To start using NexusAop in your .NET 5.0 project, follow these simple steps:
- <b>Install the Package:</b><br />
dotnet add package NexusAop
<br /><br />
2. <b>Apply Custom Attributes:</b><br />
Decorate your methods with custom attributes to define the desired cross-cutting concerns.
[CustomAspect]
public async Task<int> MyMethodAsync()
{
// Your method implementation
}
- <b>Integrate Aspect-Oriented Behavior: </b><br />
Use the provided methods such as NextAsync() and ExecuteAndGetResultAsync() within your custom aspects to influence the method execution flow.
public class CustomAspectAttribute : NexusAopAttribute
{
public override async Task ExecuteAsync(NexusAopContext context)
{
// Perform actions before the method execution
// Proceed with the execution of the target method
var result = await context.NextAsync();
// User-defined logic after the target method
// Get the result if you needed
var setResult= await context.ExecuteAndGetResultAsync();
return result;
}
}
- <b>Build and Run: </b><br />
Build your project, and NexusAop will seamlessly weave the specified aspects into your methods during runtime.
Cache Attribute Example
public class CacheMethodAttribute : NexusAopAttribute
{
public CacheMethodAttribute(
int ttlAsSecond)
{
Ttl = TimeSpan.FromSeconds(ttlAsSecond);
}
public CacheMethodAttribute()
{
Ttl = null;
}
public TimeSpan? Ttl { get; set; }
public override async Task ExecuteAsync(NexusAopContext context)
{
if (!CheckMethodCacheable(context.TargetMethod))
{
return;
}
var cacheKey = GetCacheKey(context.TargetMethod, context.TargetMethodsArgs);
var result = GetResult(cacheKey);
if (result != null)
{
context.Result= result;
return;
}
result = await context.ExecuteAndGetResultAsync();
await SetCacheAsync(context.TargetMethod, context.TargetMethodsArgs,result);
}
// ...
// see CacheMethodAttribute.cs in /Samples/Cache for other logics
// ...
}
Contributions
Contributions are welcome! If you encounter any issues or have suggestions for improvements, please feel free to create an issue or submit a pull request.
License
This project is licensed under the MIT License.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 is compatible. 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. |
-
net5.0
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 6.0.0-rc.1.21451.13)
- Microsoft.Extensions.Logging.Abstractions (>= 6.0.0-rc.1.21451.13)
- Newtonsoft.Json (>= 13.0.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.