So I am interested in the way that it is implemented. Basically: How can I re-implement the same thing myself? ... which I am not intending to do. Just understand.
The fundamental question is: How is it possible to (?) intercept class instantiation at all? And how can it be replaced in one case with one implementation and in another occurence with it's original or an even different implementation?
How is it even possible to intercept static methods or sealed classes.
This is all about shims/moles not so much about stubs.