예제 #1
0
        //Registers all custom filters in the assembly passed as a parameter
        private static void RegisterCustomFiltersInAssembly(Assembly assembly)
        {
            //Custom filters are obtained from classes in the Filters namespace that implement the IFilterFactory interface
            var filterFactories = from c in assembly.GetTypes()
                                  where c.IsClass && c.Namespace == CUSTOM_FILTERS_NAMESPACE && typeof(IFilterFactory).IsAssignableFrom(c)
                                  select c;

            //Register each filter globally using its factory method (GetFilterType)
            filterFactories.ToList().ForEach(filterFactoryClass =>
            {
                IFilterFactory ff = (IFilterFactory)Activator.CreateInstance(filterFactoryClass);
                Template.RegisterFilter(ff.GetFilterType());
            });
        }