Skip to content

Instantly share code, notes, and snippets.

@mgroves
Created February 9, 2012 03:38
Show Gist options
  • Select an option

  • Save mgroves/1777078 to your computer and use it in GitHub Desktop.

Select an option

Save mgroves/1777078 to your computer and use it in GitHub Desktop.
SheepAspect Hello World
using System;
using SheepAspect.Attributes;
using SheepAspect.Runtime;
namespace SheepAspectExample
{
class Program
{
static void Main(string[] args)
{
var obj = new MyClass();
obj.DoStuff();
}
}
public class MyClass
{
public void DoStuff()
{
Console.WriteLine("inside of DoStuff()");
}
}
[Aspect]
public class HelloWorldAspect
{
[SelectMethods("Public & InType: 'SheepAspectExample.MyClass'")]
public void MyPointcut() {}
[Around("MyPointcut")]
public object InterceptMethod(MethodJointPoint jp)
{
Console.WriteLine("Before {0}", jp.Method.Name);
var result = jp.Execute();
Console.WriteLine("After {0}", jp.Method.Name);
return result;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment