main
1using System;
2using System.Reflection;
3using Spec.Dox.Utility.Core;
4
5namespace Spec.Dox.Domain
6{
7 public interface IMethodIsDecoratedBySpecificationAttribute : ISpecification<MethodInfo> {}
8
9 public class MethodIsDecoratedBySpecificationAttribute : IMethodIsDecoratedBySpecificationAttribute
10 {
11 readonly string name_of_the_attribute_to_lookup;
12
13 public MethodIsDecoratedBySpecificationAttribute() : this(Environment.GetCommandLineArgs()[2]) {}
14
15 public MethodIsDecoratedBySpecificationAttribute(string nameOfAttributeToLookup)
16 {
17 name_of_the_attribute_to_lookup = nameOfAttributeToLookup;
18 }
19
20 public bool IsSatisfiedBy(MethodInfo item)
21 {
22 foreach (var attribute in item.GetCustomAttributes(true))
23 {
24 if (attribute.GetType().Name.Equals(name_of_the_attribute_to_lookup))
25 return true;
26 }
27 return false;
28 }
29 }
30}