main
 1using System;
 2using System.Collections.Generic;
 3using gorilla.commons.utility;
 4
 5namespace Gorilla.Commons.Infrastructure.Reflection
 6{
 7    public class ApplicationAssembly : Assembly
 8    {
 9        IList<Type> types = new List<Type>();
10
11        public ApplicationAssembly(params System.Reflection.Assembly[] assemblies)
12        {
13            assemblies.each(x => types.add_range(x.GetTypes()));
14        }
15
16        public IEnumerable<Type> all_types()
17        {
18            return types;
19        }
20
21        public IEnumerable<Type> all_types(Specification<Type> matching)
22        {
23            return all_types().where(x => matching.is_satisfied_by(x));
24        }
25
26        public IEnumerable<Type> all_classes_that_implement<Contract>()
27        {
28            return all_types()
29                .where(x => typeof (Contract).IsAssignableFrom(x))
30                .where(x => !x.IsInterface)
31                .where(x => !x.IsAbstract)
32                .where(x => !x.IsGenericType);
33        }
34    }
35}