main
 1using System;
 2using System.Collections.Generic;
 3using System.Linq;
 4
 5namespace jive
 6{
 7  public static class RegistryExtensions
 8  {
 9    public static K find_an_implementation_of<T, K>(this Registry<T> registry) where K : T
10    {
11      try
12      {
13        return registry
14          .all()
15          .Single(p => p.is_an_implementation_of<K>())
16          .downcast_to<K>();
17      }
18      catch (Exception exception)
19      {
20        throw new Exception("Could Not Find an implementation of".format(typeof (K)), exception);
21      }
22    }
23
24    public static IEnumerable<T> sort_all_using<T>(this Registry<T> registry, IComparer<T> comparer)
25    {
26      return registry.all().sorted_using(comparer);
27    }
28  }
29}