python from silk.inject.context import SilkContext, SilkModule class UserService: def get_username(self): pass class UserServiceImpl(UserService): def get_username(self): return "John Doe" class MyAppModule(SilkModule): def configure(self, binder): binder.bind(UserService, to=UserServiceImpl) context = SilkContext(MyAppModule()) user_service = context.get(UserService) username = user_service.get_username()


上一篇:
下一篇:
切换中文