Skip to content

Commit 44b50b0

Browse files
committed
Inject AdviceRegistry into ProxyActivationStrategy instead of getting it from the kernel on each request.
1 parent d8980c9 commit 44b50b0

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/Ninject.Extensions.Interception/Activation/Strategies/ProxyActivationStrategy.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,13 @@ namespace Ninject.Extensions.Interception.Activation.Strategies
2727
/// </summary>
2828
public class ProxyActivationStrategy : ActivationStrategy
2929
{
30+
private readonly IAdviceRegistry adviceRegistry;
31+
32+
public ProxyActivationStrategy(IAdviceRegistry adviceRegistry)
33+
{
34+
this.adviceRegistry = adviceRegistry;
35+
}
36+
3037
/// <summary>
3138
/// Activates the specified context.
3239
/// </summary>
@@ -61,9 +68,9 @@ public override void Deactivate( IContext context, InstanceReference reference )
6168
/// </summary>
6269
/// <param name="context">The activation context.</param>
6370
/// <returns><see langword="True"/> if the instance should be proxied, otherwise <see langword="false"/>.</returns>
64-
protected virtual bool ShouldProxy( IContext context )
71+
protected virtual bool ShouldProxy(IContext context)
6572
{
66-
if (context.Kernel.Components.Get<IAdviceRegistry>().HasAdvice(context))
73+
if (this.adviceRegistry.HasAdvice(context))
6774
{
6875
return true;
6976
}

0 commit comments

Comments
 (0)