|
1 | 1 | # Ninject.Extensions.Interception |
2 | 2 |
|
3 | | -[](https://www.nuget.org/packages/Ninject.Extensions.Interception/) |
4 | | -[](https://ci.appveyor.com/project/scott-xu/ninject-extensions-interception) |
| 3 | +[](https://ci.appveyor.com/project/Ninject/ninject-extensions-interception) |
5 | 4 | [](https://codecov.io/gh/ninject/Ninject.Extensions.Interception) |
| 5 | +[](https://www.nuget.org/packages/Ninject.Extensions.Interception/) |
| 6 | +[](https://www.nuget.org/packages/Ninject.Extensions.Interception/) |
| 7 | + |
| 8 | +This extension adds support for interception to Ninject. |
| 9 | + |
| 10 | +For example, the WCF client proxy can be intercepted as below. |
6 | 11 |
|
7 | | -ChannelProxies can be intercepted now: |
8 | 12 | ```C# |
9 | | - [ServiceContract] |
10 | | - public interface IFooService |
11 | | - { |
12 | | - [OperationContract] |
13 | | - void Foodo(); |
14 | | - } |
| 13 | +[ServiceContract] |
| 14 | +public interface IFooService |
| 15 | +{ |
| 16 | + [OperationContract] |
| 17 | + void Foodo(); |
| 18 | +} |
15 | 19 |
|
16 | | - ActionInterceptor interceptor = |
17 | | - new ActionInterceptor( invocation => Console.WriteLine("Executing {0}.", invocation.Request.Method) ); |
| 20 | +var interceptor = |
| 21 | + new ActionInterceptor( |
| 22 | + invocation => Console.WriteLine($"Executing {invocation.Request.Method}.")); |
18 | 23 |
|
19 | | - kernel.Bind<IFooService>() |
20 | | - .ToMethod(context => ChannelFactory<IFooService>.CreateChannel(new NetTcpBinding(), new EndpointAddress("net.tcp://localhost/FooService"))) |
21 | | - .Intercept(typeof(ICommunicationObject)) |
22 | | - .With(interceptor); |
| 24 | +kernel.Bind<IFooService>() |
| 25 | + .ToMethod(context => ChannelFactory<IFooService>.CreateChannel("*")) |
| 26 | + .Intercept(typeof(ICommunicationObject)) |
| 27 | + .With(interceptor); |
23 | 28 | ``` |
0 commit comments