dI.Hook - How to create a HookRepository?
If you are new to dI.Hook, please visit the product page for Overview, Release Version and Source Code.
What is hook and a repository?
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.
Repository – A Container, or Collection of Hooks. There are two types of repositories:
- Standard Repository – HookRepository: This repository contains collection of instances of hooks
- Lazy Repository – LazyHookRepository: This repository is a collection of type of hooks. In this repository, the instance of a hook is created when it is invoked first time unless actually an instance is added explicitly.
How to create a repository?
Once you have decided the type of repository you want to create, you can choose one of the many ways of creating a repository
Creating a repository using HookRepositoryFactory
- IHookRepository<IHook> repository =
- HookRepositoryFactory.Create<IHook>(true);
- IHookRepository<IHook> repository =
- HookRepositoryFactory.Create<IHook>(false);
This repository is very light-weight and does not have any hooks in it. So the next article would be to add hooks into this repository