PageRenderTime 51ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/src/SampleLibrary/IOC/SampleInterceptorClass.cs

http://github.com/philiplaureano/LinFu
C# | 29 lines | 23 code | 5 blank | 1 comment | 0 complexity | 7ccf0c6748232183216d0a7aaf916b32 MD5 | raw file
  1. using LinFu.AOP.Interfaces;
  2. using LinFu.IoC;
  3. using LinFu.IoC.Configuration;
  4. using LinFu.IoC.Interceptors;
  5. using LinFu.IoC.Interfaces;
  6. namespace SampleLibrary.IOC
  7. {
  8. [Intercepts(typeof(ISampleInterceptedInterface))]
  9. public class SampleInterceptorClass : IInterceptor, IInitialize, ITargetHolder
  10. {
  11. public void Initialize(IServiceContainer source)
  12. {
  13. var typeName = GetType().Name;
  14. source.AddService<ITargetHolder>(typeName, this);
  15. }
  16. public object Intercept(IInvocationInfo info)
  17. {
  18. // Set the target on every method call
  19. Target = info.Target;
  20. return null;
  21. }
  22. public object Target { get; set; }
  23. }
  24. }