public static void BindValidators(this IKernelConfiguration config, Assembly assembly)
 {
     foreach (var type in assembly.GetTypes().Where(t => t.GetInterfaces().Any(i => i.IsConstructedGenericType == true && i.GetGenericTypeDefinition() == typeof(IValidator <>))))
     {
         foreach (Type validator in type.GetInterfaces().Where(i => i.IsConstructedGenericType == true && i.GetGenericTypeDefinition() == typeof(IValidator <>)))
         {
             config
             .Bind(validator)
             .To(type);
         }
     }
 }
 public static void BindPermissionChecks(this IKernelConfiguration config, Assembly assembly)
 {
     foreach (var type in assembly.GetTypes().Where(t => t.GetInterfaces().Any(i => i.IsConstructedGenericType == true && i.GetGenericTypeDefinition() == typeof(IPermissionCheck <>))))
     {
         foreach (Type permissionCheck in type.GetInterfaces().Where(i => i.IsConstructedGenericType == true && i.GetGenericTypeDefinition() == typeof(IPermissionCheck <>)))
         {
             config
             .Bind(permissionCheck)
             .To(type);
         }
     }
 }
Example #3
0
 public static void BindToMethod <T>(this IKernelConfiguration config, Func <T> method) => config.Bind <T>().ToMethod(c => method());