Der*_*ins 6 structuremap dependency-injection interceptor
我有一堆实现各种接口的服务.例如IAlbumService,IMediaService等
我想在这些接口上记录对每个方法的调用.如何使用StructureMap执行此操作?
我意识到这与这个问题几乎相同,只是因为我没有使用windsor.
我想你正在寻找这个答案。
static void Main()
{
ObjectFactory.Configure(x =>
{
x.For<Form>().Use<Form1>()
.InterceptWith(new ActivatorInterceptor<Form1>(y => Form1Interceptor(y), "Test"));
});
Application.Run(ObjectFactory.GetInstance<Form>());
}
public static void Form1Interceptor(Form f)
{
//Sets the title of the form window to "Testing"
f.Text = "Testing";
}
Run Code Online (Sandbox Code Playgroud)
我不会在实际应用程序中使用 ObjectFactory,但至少有这个概念。