2 using Hammock.Specifications;
4 namespace Hammock.Extensions
6 internal static class SpecificationExtensions
8 public static bool Satisfies<T>(this object instance) where T : ISpecification
10 var marker = Activator.CreateInstance<T>();
11 var type = typeof (ISpecification<>).MakeGenericType(instance.GetType());
12 var match = marker.Implements(type);
19 var method = type.GetMethod("IsSatisfiedBy");
20 var result = method.Invoke(marker, new[] {instance});
25 public static bool Satisfies(this object instance, ISpecification specificationType)
27 var type = typeof (ISpecification<>).MakeGenericType(instance.GetType());
28 var match = specificationType.Implements(type);
35 var method = type.GetMethod("IsSatisfiedBy");
36 var result = method.Invoke(specificationType, new[] {instance});