If you are new to dI.Hook, please visit the product page for Overview, Release Version and Source Code.
Hook – A hook is a .NET object derived from the interface IHook. If you already have classes that have business/technical functionalities, implementing IHook will not impact their functionality. If your classes have similar function names, it is advisable to explicitly implement interface IHook.
To illustrate this, let’s create two hooks LogHook and DiagnosticsHook. We will not focus on their implementation and limit our scope to their definition and adding them to HookRepository
DiagnosticsHook – Implements multiple interfaces (IHook, required for HookRepository) and IAdditionalInterface
How to add an instance of a hook in a repository?
When we are referring to adding an instance of a hook in a repository, there are multiple ways of doing it
Method 1 – Adding one hook instance at a time
Method 2 – Adding a List of hooks
Method 3 – Adding two different instances of same hook type
Method 4 – Adding by searching within an Assembly
Method 5 – Adding by searching within a directory
How to add a type of a hook in a repository?
If your repository supports lazy loading, then adding a type of hook in a repository is preferred over adding an instance of a hook. By adding a type in the repository, the instance of hook is not created until it is invoked or searched for.
However, if your repository does not support lazy loading you can choose any mechanism of adding hook into repository
So you can add a hook by six different ways in a Hook Repository