public static T SingleOrDefault <T>(this IDirectiveCollection directives) => directives .Where(t => typeof(T).IsAssignableFrom(t.Type.RuntimeType)) .Select(t => t.ToObject <T>()).SingleOrDefault();
private static IReadOnlyCollection <IDirective> GetValidationDirectives(IDirectiveCollection collection) { return(collection.Where(d => d.Type is IValidationDirectiveType).ToList()); }