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