我使用 C# Visual Studio 2008.net 编写了方面类和目标类,但每次我运行应用程序以交织它们时,只执行目标类但我无法执行方面类我试图附加对剑杆织机的引用并试图卸载剑杆织机并重新安装,但出现同样的问题....问题是什么?
这是方面类:
using System;
using Loom;
using Loom.JoinPoints;
namespace HelloAspect
{
public class TraceAspect : Aspect
{
[Loom.JoinPoints.IncludeAll]
[Call(Advice.Around)]
public T Trace<T>([JPContext]Context ctx, params object[] args)
{
Console.WriteLine(ctx.Instance + "." + ctx.CurrentMethod.Name + " called");
ctx.Invoke(args);
return default(T);
}
}
}
这是应用程序方法:
using System;
using Loom;
using Loom.JoinPoints;
namespace HelloAspect
{
class Program
{
static void Main(string[] args)
{
string name;
Console.Write("Your name: ");
name = Console.ReadLine();
TraceAspect aspect1 = new TraceAspect();
Target target = Loom.Weaver.Create<Target>(aspect1);
target.Hello(name);
Console.ReadLine();
}
}
}
目标类是:
public class Target
{
public virtual void Hello(string name)
{
Console.WriteLine("Hello {0}!", name);
}
}