This project is read-only.

Business Classes

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.

In CrowFX 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;
  1. Before Method Execution
  2. After Method Execution
  3. 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 RuleValidationAttribute()
        {
        }

        [WorksBefore]
        public void MethodExecuting(IMethodInvocationContext context)
        {
            if (context.Args.Length == 0) context.Cancel = true;
            else context.Proceed();
        }
    }

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 Proceed(); method of the context.

Aspect methods has to have a one parameter which is IMethodInvocationContext. This is necessery for the aspect's nature in CrowFX. 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 ;
  1. Cache
  2. HandleError
  3. Log
  4. Trace

Last edited Aug 10, 2012 at 1:32 PM by msusur, version 1

Comments

No comments yet.