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