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://dihook.codeplex.com/
Download latest release version - https://dihook.codeplex.com/releases/view/91887
How to reference this assembly in your project?
Manually add the assembly – use CodePlex
How to Series
- How to create a HookRepository?
- How to add hooks to HookRepository?
- How to add hooks via configuration file to a HookRepository?
- How to invoke all hooks?
- How to invoke hooks that satisfy a condition?
- How to retrieve an object of hook?
- How to remove hooks from HookRepository?
- How to ignore hook on specific method?
- How to use Dependency Injection Container?