Business classes are the objects that operates the business needs for the application. These classes are simply same as the Presenters in the MVP pattern. Their only purpose is to get the domain entities from UI Layer and make the needed operations then transfer
the entities to the Repositories.
Applying Aspects to the Business classes
Aspects are the most enjoying part of this project. We use aspects in order to achive a seperation between the business logic and some other things that are not belong to the that business such as logging, exception handling, cache etc.
there are some aspects implemented for developers use however you can add your own aspects and allow them to be run at your business codes.
There are three windows you can intercept while the method is executed;
- Before Method Execution
- After Method Execution
- On Method throws an Exception
This means you have all the control over the methods.
Let's see this example;
public sealed class RuleValidationAttribute : AspectAttributeBase
public void MethodExecuting(IMethodInvocationContext context)
if (context.Args.Length == 0) context.Cancel = true;
In this example, MethodExecuting marked as WorksBefore
which means this method is going to be triggered before the actually called method is invoked. And in the body, method makes a check for the arguments of the context variable. Aspect methods can
prevent the invoked method to be executed or it can also execute method itself by calling the
method of the context.
Aspect methods has to have a one parameter which is IMethodInvocationContext
. This is necessery for the aspect's nature in
. With this context, developers can interfere the invocation or manipulate the method invocation. It can redesign the method arguments or cancel the process.
Predefined aspects are ;