コード例 #1
0
 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);
         }
     }
 }
コード例 #2
0
 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);
         }
     }
 }
コード例 #3
0
 public static void BindToMethod <T>(this IKernelConfiguration config, Func <T> method) => config.Bind <T>().ToMethod(c => method());