dI.Hook (pronounced as, du’ hʊk) is a Hook Repository Framework that allows making a component run-time rather than compile time.  It internally uses Dependency Injection pattern principles to define hooks via code or configuration, call them dynamically or conditionally and dispose them when not required.  However, this is not yet another dependency injection framework.  So how this is different?

  • dI.Hook creates a controlled repository of hooks instead of searching & instantiating a hook at a time when required
  • dI.Hook allows lazy-loads the hook objects at run-time, thereby optimizing the memory allocation and performance
  • dI.Hook allows addition of hooks by both hook-type and live hook instance thereby
    • allowing sharing of hook instances between multiple repositories and/or
    • adding multiple hooks of same type with different attributes in a single repository
  • dI.Hook allows creating a hierarchy of hooks
  • dI.Hook promotes both repository based hooks and method based hooks -
    • Hooks can now be stored in a repository or
    • The repository can be designed light-weight and methods could be decorated by Hook Attributes
  • Hooks can be invoked conditionally using C# Funcs, delegates and Actions
  • Hooks can be invoked sequentially (as blocking calls) or parallel (in separate threads)

The framework is not backward compatible with .NET 2.0, 3.0 or 3.5 as it heavily uses features of .NET 4.0.  It is 100% unit tested (MS-Test).

Where’s the code?

The latest release and the source code can be downloaded from CodePlex.  The code is distributed under GPL v2 license.

CodePlex Homepage - https://www.github.com/punitganshani/dihook/

Download latest release version - https://www.github.com/punitganshani/dihook/

How to reference this assembly in your project?

Use Nuget

Manually add the assembly - use CodePlex

How to Series

  1. How to create a HookRepository?
  2. How to add hooks to HookRepository?
  3. How to add hooks via configuration file to a HookRepository?
  4. How to invoke all hooks?
  5. How to invoke hooks that satisfy a condition?
  6. How to retrieve an object of hook?
  7. How to remove hooks from HookRepository?
  8. How to ignore hook on specific method?
  9. How to use Dependency Injection Container?