Aspect class code can't be interwoven with target class code in Rapier-LOOM
-
06-04-2021 - |
题
I wrote the aspect class and the target class 'using C# Visual Studio 2008.net' but every time I run the application to interweave them only the target class executed but I can't execute aspect class i tried to attach references to rapier-loom and tried to uninstall rapier-loom and install it again but the same problem occurs....what is the problem ?
this is the aspect class:
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);
}
}
}
this is the Application method:
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();
}
}
}
the Target class is:
public class Target
{
public virtual void Hello(string name)
{
Console.WriteLine("Hello {0}!", name);
}
}
没有正确的解决方案
其他提示
The problem is that you implicitly call the ToString()
method of the Target class from your advice method via the ctx.Instance
call. This will lead in a endless recursion because ToString is also interwoven by the advice method.
不隶属于 StackOverflow