Exemplo n.º 1
0
        /// <summary>
        /// Scans assembly and registers all policies found.
        /// Uses dependency resolver
        /// </summary>
        /// <param name="conventions"></param>
        /// <param name="asm"></param>
        public static void RegisterConventions(this FiltersConventions conventions, Assembly asm)
        {
            var resolve = DependencyResolver.Current;

            asm.GetTypesDerivedFrom <IFilterConvention>()
            .Select(t => resolve.GetService(t))
            .Cast <IFilterConvention>()
            .ForEach(f =>
            {
                conventions.Conventions.Add(f);
            });
        }
Exemplo n.º 2
0
 public static void RegisterControllers(this FiltersConventions conventions, params Type[] controllers)
 {
     foreach (var c in controllers)
     {
         if (!c.DerivesFrom <Controller>())
         {
             continue;
         }
         c.GetActionMethods().ForEach(m =>
         {
             conventions.Actions.Add(m);
         });
     }
 }
Exemplo n.º 3
0
 public LambdaConfigurator(FiltersConventions parent, Predicate <MethodInfo> predicate)
 {
     _parent = parent;
     _lambda = new LambdaHostConvention(predicate);
 }
Exemplo n.º 4
0
 public static void RegisterModules(this FiltersConventions filters, params Assembly[] assemblies)
 {
     assemblies.SelectMany(a => a.GetTypesDerivedFrom <FiltersConventionsModule>(true))
     .ForEach(t => filters.LoadModule(t.CreateInstance() as FiltersConventionsModule));
 }
Exemplo n.º 5
0
 /// <summary>
 /// Builds the conventions and registers them to be used by asp.net mvc
 /// </summary>
 /// <param name="filters"></param>
 public static void BuildAndEnable(this FiltersConventions filters)
 {
     filters.RegisterProvider(FilterProviders.Providers);
 }
Exemplo n.º 6
0
 /// <summary>
 /// Register as actions types matching a criteria
 /// </summary>
 /// <param name="conventions"></param>
 /// <param name="asm"></param>
 /// <param name="match"></param>
 public static void Register(this FiltersConventions conventions, Assembly asm, Func <Type, bool> match)
 {
     RegisterControllers(conventions, asm.GetTypes().Where(match).ToArray());
 }
Exemplo n.º 7
0
 public static void RegisterController <T>(this FiltersConventions conventions) where T : Controller
 {
     conventions.RegisterControllers(typeof(T));
 }
Exemplo n.º 8
0
 public static void RegisterControllers(this FiltersConventions conventions, Assembly asm)
 {
     RegisterControllers(conventions, asm.GetControllerTypes().ToArray());
 }