this code should be out of here, (also in DI) when you add the constraint you should test that it's from the right type. You probably want to have a generic api surface to register them to avoid confusion