I have a bunch of services that implement various interfaces. eg, IAlbumService
, IMediaService
etc.
I want to log calls to each method on these interfaces. How do I do this using StructureMap?
I realise this is pretty much the same as this question it is just that I am not using windsor.
I think you are looking for this answer.
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";
}
I wouldn't use ObjectFactory in a real application, but at least the concept is there.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With