@@ -29,7 +29,7 @@ $ pip install py-dependency-injection
29
29
30
30
The following examples demonstrates how to use the library.
31
31
32
- #### Example: Obtaining the Default Dependency Container
32
+ ### Example: Obtaining the Default Dependency Container
33
33
34
34
``` python
35
35
# Retrieve the default container, typically recommended for a single-application setup.
@@ -40,7 +40,7 @@ from dependency_injection.container import DependencyContainer
40
40
dependency_container = DependencyContainer.get_instance()
41
41
```
42
42
43
- #### Example: Obtaining a Second Dependency Container
43
+ ### Example: Obtaining a Second Dependency Container
44
44
45
45
``` python
46
46
# Create additional containers if needed, especially for multi-application scenarios.
@@ -51,7 +51,7 @@ from dependency_injection.container import DependencyContainer
51
51
a_second_dependency_container = DependencyContainer.get_instance(name = " a_second_dependency_container" )
52
52
```
53
53
54
- #### Example: Registering Dependencies
54
+ ### Example: Registering Dependencies
55
55
56
56
``` python
57
57
# Register dependencies with three available scopes: transient, scoped, or singleton.
@@ -61,7 +61,7 @@ dependency_container.register_scoped(AnotherInterface, AnotherClass)
61
61
dependency_container.register_singleton(ThirdInterface, ThirdClass)
62
62
```
63
63
64
- #### Example: Resolving Dependencies
64
+ ### Example: Resolving Dependencies
65
65
66
66
``` python
67
67
# Resolve transient instance (created anew for each call).
@@ -74,7 +74,7 @@ scoped_instance = dependency_container.resolve(AnotherInterface, scope_name="app
74
74
singleton_instance = dependency_container.resolve(ThirdInterface)
75
75
```
76
76
77
- #### Example: Constructor Injection
77
+ ### Example: Constructor Injection
78
78
79
79
``` python
80
80
# Class instances resolved through the container have dependencies injected into their constructors.
@@ -87,7 +87,7 @@ class Foo:
87
87
self ._singleton_instance = singleton_instance
88
88
```
89
89
90
- #### Example: Method Injection
90
+ ### Example: Method Injection
91
91
92
92
``` python
93
93
# Inject dependencies into instance methods using the `@inject` decorator.
0 commit comments