Skip to content

AntyaDev/KingAOP

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

67 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

#KingAOP

It's an AOP framework which is essentially a free alternative of PostSharp. If you familiar with PostSharp, then you can notice that KingAOP has even the same interfaces to interract with you:)

The concept of aspect-oriented programming (AOP) offers an interesting alternative for the specification of non-functional component properties (such as fault-tolerance properties or timing behaviour), as well as other crosscutting concerns. These are implemented as so-called aspects and at some point "weaved" to the other functional parts of the software.

##How it works? It‘s use a dynamic opportunities of C# 4.0 instead of IL rewriting technique which the PostSharp use. And that brings us to a predictable and clean model. You can look through an AOP weaving stuff in very easy way.

##A Basic example:

  • Implement a hello world aspect.
class HelloWorldAspect : OnMethodBoundaryAspect
{
    public override void OnEntry(MethodExecutionArgs args)
    {
        Console.WriteLine("OnEntry: Hello KingAOP");
    }

    public override void OnExit(MethodExecutionArgs args)
    {
        Console.WriteLine("OnExit: Hello KingAOP");
    }
}
  • Add the hello aspect to some class.
class HelloWorld : IDynamicMetaObjectProvider
{
    [HelloWorldAspect]
    public void HelloWorldCall()
    {
        Console.WriteLine("Hello World");
    }

    public DynamicMetaObject GetMetaObject(Expression parameter)
    {
        return new AspectWeaver(parameter, this);
    }
}
  • Enjoy.
dynamic helloWorld = new HelloWorld();
helloWorld.HelloWorldCall();

About

.NET AOP framework - a free alternative of PostSharp.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages