As the title says, is this possible? Here's my code:
public class RequiresTransactionAttribute : Attribute
{
}
public interface IFoo
{
void DoSomething();
}
public class Foo : IFoo
{
[RequiresTransaction]
public void DoSomething()
{
// ...
}
}
container.Register<IFoo, Foo>();
container.Intercept(sr => sr.ServiceType == typeof(IFoo), (sf, pd) => DefineProxyType(sf, pd));
private void DefineProxyType(IServiceFactory sf, ProxyDefinition pd)
{
pd.Implement(() => sf.GetInstance<IInterceptor>(), mi => mi.GetCustomAttribute<RequiresTransactionAttribute>() != null);
}
This is not working, as I'm getting, in the proxy definition, a reference to the type IFoo (which doesn't have the attribute), instead of the target Foo. If I do this:
public interface IFoo
{
[RequiresTransaction]
void DoSomething();
}
Then the method is intercepted. But I would like to avoid setting the attribute in the interface.
Hello,
As the title says, is this possible? Here's my code:
This is not working, as I'm getting, in the proxy definition, a reference to the type IFoo (which doesn't have the attribute), instead of the target Foo. If I do this:
Then the method is intercepted. But I would like to avoid setting the attribute in the interface.