private static void HandleHooks(GitHookContext fileParseResult) { var assembly = Assembly.LoadFrom(fileParseResult.AssemblyPath); var types = assembly.GetTypes().Where(o => !o.IsInterface && typeof(IGitHook).IsAssignableFrom(o)); foreach (var type in types) { HandleHook(fileParseResult, type); } }
static BaseHookHandler GetHandler(GitHookContext context) { switch (context.Type) { case HookType.PreCommit: return(new PreCommitHookHandler(context)); default: throw new NotSupportedException(); } }
static void HandleHook(GitHookContext context, Type type) { var handler = GetHandler(context); handler.Handle(type); }
public PreCommitHookHandler(GitHookContext context) { _context = context; }