If you are new to dI.Hook, please visit the di.Hook Product Page for Overview, Release Version and Source Code.
Some posts you might want to read would be:
- 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 using dI.Hook?
- How to invoke hooks that satisfy a condition?
- How to retrieve an object of hook?
- How to remove hooks from HookRepository?
So this is the eighth article in the series which will deal with
– Ignoring one or more hook objects when executing OnInvoke in a method
– but NOT removing the hook from the repository
Step 1 – Creating a repository and add hooks into a repository
The first decision in creating a hook repository is to think whether you want to have lazy loading or not. Once you have decided you can go through the steps – Creating a Hook Repository using dI.Hook
Be selective in adding hooks into a repository if you plan to invoke all of them at one go. If you are thinking of manually adding hooks to a repository, would suggest going through – Adding hooks manually into a repository. However, if you are planning to load them through configuration you can read – Loading a configuration set of hooks into repository
How to ignore a hook being invoked on a method?
The repository created in step 1 consists of 2 hooks.
Method One – Ignoring all hooks
Method Two – Ignoring hooks with particular name
or, you can have multiple hook names in the list
or, using multiple attributes for doing the same
Method Three – Ignore a hook of specific type
So using these techniques, you can have a method ignore one or many hooks. These hooks will still remain in the repository and methods without these attributes will continue to invoke their OnInvoke method.