AOP 1.0.2

There is a newer version of this package available.
See the version list below for details.
dotnet add package AOP --version 1.0.2
NuGet\Install-Package AOP -Version 1.0.2
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="AOP" Version="1.0.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add AOP --version 1.0.2
#r "nuget: AOP, 1.0.2"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install AOP as a Cake Addin
#addin nuget:?package=AOP&version=1.0.2

// Install AOP as a Cake Tool
#tool nuget:?package=AOP&version=1.0.2

AOP

AOP is a library for use the Aspect Oriented approach in a .net project.

Usage:

interface IService {
	void DoWork();
}

class Service : IService {
	public void DoWork() {
		Console.WriteLine("Do work ...");
	}
}

/// <summary>
/// Your aspect
/// </summary>
/// <typeparam name="T"></typeparam>
class MyAspect<T> : Aspect<T>, IBeforeAdvice, IAroundAdvice, IAfterAdvice, IAfterThrowAdvice where T : class
{
	public MyAspect()
	{

	}

	public void OnBefore(ExecutionContext context)
	{
		//code executed before
	}

	public AroundExecutionResult OnAround(ExecutionContext context)
	{
		//code executed around
		
		return new AroundExecutionResult
		{
			Proceed = true,
			OverwrittenResult = null
		};
	}

	public void OnAfter(ExecutionContext context, object result)
	{
		//code executed after
	}

	public void OnThrow(ExecutionContext context, Exception exception)
	{
		//code executed on exception throw
	}
}

//IService and Service are your object/service class to observe/control

var aspect = new MyAspect<IService>();

IService service = aspect.Build(new Service());

service.DoWork();

Features

  • It manages Before, Around (with execution control), After and Throw pointcuts
  • It allows the aspect waterfall (chain) in order to register different aspects on the same object

Todos

  • Test coverage
  • Manage task execution

License

MIT

THIS SOFTWARE IS PROVIDED "AS IS" BY THE OWNER AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OWNER BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Product Compatible and additional computed target framework versions.
.NET Framework net46 is compatible.  net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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.1.2 249 8/8/2023
1.1.1 507 9/30/2022
1.1.0 468 10/30/2021
1.0.2 912 9/8/2019
1.0.1 664 9/6/2019
1.0.0 690 9/5/2019
0.0.3 674 9/4/2019
0.0.2 630 9/2/2019
0.0.1 631 9/2/2019
0.0.0 645 9/1/2019