/src/LinFu.IoC/Interceptors/InterceptsAttribute.cs

http://github.com/philiplaureano/LinFu · C# · 40 lines · 18 code · 4 blank · 18 comment · 0 complexity · 1414d45b2c437f9093d78fcd4b424a05 MD5 · raw file

  1. using System;
  2. namespace LinFu.IoC.Interceptors
  3. {
  4. /// <summary>
  5. /// The attribute class used to indentify interceptor classes.
  6. /// </summary>
  7. [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
  8. public class InterceptsAttribute : Attribute
  9. {
  10. /// <summary>
  11. /// Initializes the class with the given <paramref name="targetType" />.
  12. /// </summary>
  13. /// <param name="targetType">The target type that will be intercepted.</param>
  14. public InterceptsAttribute(Type targetType)
  15. {
  16. TargetType = targetType;
  17. }
  18. /// <summary>
  19. /// Initializes the class with the given <paramref name="targetType" /> and <paramref name="serviceName" />.
  20. /// </summary>
  21. /// <param name="serviceName">The name of service that will be intercepted.</param>
  22. /// <param name="targetType">The target type that will be intercepted.</param>
  23. public InterceptsAttribute(string serviceName, Type targetType) : this(targetType)
  24. {
  25. ServiceName = serviceName;
  26. }
  27. /// <summary>
  28. /// Gets the value indicating the name of the service to intercept.
  29. /// </summary>
  30. public string ServiceName { get; }
  31. /// <summary>
  32. /// Gets the value indicating the target type that will be intercepted.
  33. /// </summary>
  34. public Type TargetType { get; }
  35. }
  36. }