def configure_stacked_binding_and_lifetime(config: Config): config.bind(SB1, SB2) config.lifetime(SB2, Lifetime.SINGLETON) config.bind(SB2, SB3)
def configure_lifetime_with_context(config: Config): config.bind(T, foo) config.arguments(foo, a=1, where=UseT1) config.arguments(foo, a=2, where=UseT2) config.lifetime(foo, Lifetime.SINGLETON, where=UseT2) config.lifetime(foo, where=UseT3, lifetime=Lifetime.SINGLETON)
def configure_singleton_with_context(config: Config): config.arguments(T, a=1, where=UseT1) config.arguments(T, a=2, where=UseT2) config.lifetime(T, Lifetime.SINGLETON, where=UseT1) config.lifetime(T, Lifetime.SINGLETON, where=UseT2)
def configure_bind_singleton(config: Config): config.bind(MyInterface, MyImplementation) config.lifetime(MyImplementation, Lifetime.SINGLETON)
def configure_singleton(config: Config): config.arguments(Transient, a=42, b=10.0) config.lifetime(Transient, Lifetime.SINGLETON)
def configure_lifetime(config: Config): config.lifetime(MySingleton, Lifetime.SINGLETON) config.lifetime(MyTransient, Lifetime.TRANSIENT)