container
dev_tool.container
__all__ = ['CommandGroupRegistry', 'DependencyContainer', 'ServiceRegistry']
module-attribute
CommandGroupRegistry
A registry class for command group registration.
This class provides methods for registering all command groups with the dependency injection container.
register_command_groups
staticmethod
A method that registers all command groups with the container.
Parameters:
-
container(DependencyContainer) –The dependency injection container to register with.
Source code in dev_tool/container/command_registry.py
DependencyContainer
A dependency injection container for managing service instances.
This class provides methods for registering services, factories, and instances, and resolving dependencies automatically using constructor injection.
The constructor for the DependencyContainer class.
Initializes empty collections for storing factories, instances, services, and type mappings.
Source code in dev_tool/container/container.py
register
A method that registers a service type with the container.
Parameters:
-
interface(type[T]) –The interface or base class.
-
implementation(type[T] | None, default:None) –The implementation class, defaults to interface.
-
singleton(bool, default:True) –Whether to create a singleton instance.
Source code in dev_tool/container/container.py
register_factory
A method that registers a factory function with the container.
Parameters:
-
interface(type[T]) –The interface the factory creates.
-
factory(Callable[[], T]) –The factory function.
-
singleton(bool, default:True) –Whether to cache the factory result.
Source code in dev_tool/container/container.py
register_instance
A method that registers a pre-created instance with the container.
Parameters:
-
interface(type[T]) –The interface the instance implements.
-
instance(T) –The instance to register.
Source code in dev_tool/container/container.py
resolve
A method that resolves a service instance from the container.
Parameters:
Returns:
-
T–An instance of the requested service.
Raises:
-
ValueError–If the service is not registered.
Source code in dev_tool/container/container.py
ServiceRegistry
A registry class for service registration.
This class provides methods for creating and registering all services with the dependency injection container.
register_all_services
staticmethod
A method that registers all services with the dependency container.
Parameters:
-
container(DependencyContainer) –The dependency injection container to register with.
Source code in dev_tool/container/service_registry.py
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 | |