You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: AI_CONTEXT_LARGE.md
+34-52Lines changed: 34 additions & 52 deletions
Original file line number
Diff line number
Diff line change
@@ -164,7 +164,7 @@ This can be done if these methods are not needed, in case only certain compositi
164
164
165
165
## Resolve methods
166
166
167
-
This example shows how to resolve the composition roots using the _Resolve_ methods by_Service Locator_ approach. `Resolve` methods are generated automatically for each registered root.
167
+
This example shows how to resolve the roots of a composition using `Resolve` methods to use the composition as a_Service Locator_. The `Resolve` methods are generated automatically without additional effort.
168
168
169
169
```c#
170
170
usingPure.DI;
@@ -209,13 +209,10 @@ class OtherService : IService;
209
209
To run the above code, the following NuGet package must be added:
_Resolve_ methods are similar to calls to the roots of a composition. Composition roots are common properties. Their use is efficient and does not cause exceptions. And that is why it is recommended to use them. In contrast, _Resolve_ methods have a number of disadvantages:
213
-
214
-
- They provide access to an unlimited set of dependencies.
215
-
216
-
- Their use can potentially lead to runtime exceptions, for example, when the corresponding root has not been defined.
217
-
218
-
- Lead to performance degradation because they search for the root of a composition based on its type.
212
+
_Resolve_ methods are similar to calls to composition roots. Composition roots are properties (or methods). Their use is efficient and does not cause exceptions. This is why they are recommended to be used. In contrast, _Resolve_ methods have a number of disadvantages:
213
+
- They provide access to an unlimited set of dependencies (_Service Locator_).
214
+
- Their use can potentially lead to runtime exceptions. For example, when the corresponding root has not been defined.
215
+
- Sometimes cannot be used directly, e.g., for MAUI/WPF/Avalonia binding.
219
216
220
217
## Simplified binding
221
218
@@ -1649,8 +1646,8 @@ class Service : IService
1649
1646
partialclassComposition
1650
1647
{
1651
1648
privatevoidSetup() =>
1652
-
DI.Setup(nameof(Composition))
1653
1649
1650
+
DI.Setup(nameof(Composition))
1654
1651
.Arg<Serilog.ILogger>("logger", "from arg")
1655
1652
.Bind().To(ctx=>
1656
1653
{
@@ -1742,8 +1739,6 @@ using Pure.DI;
1742
1739
usingstaticPure.DI.Lifetime;
1743
1740
1744
1741
DI.Setup(nameof(Composition))
1745
-
// This hint indicates to not generate methods such as Resolve
1746
-
.Hint(Hint.Resolve, "Off")
1747
1742
.Bind().As(Transient).To<Dependency>()
1748
1743
.Bind().To<Service>()
1749
1744
.Root<IService>("Root");
@@ -1801,8 +1796,6 @@ using Pure.DI;
1801
1796
usingstaticPure.DI.Lifetime;
1802
1797
1803
1798
DI.Setup(nameof(Composition))
1804
-
// This hint indicates to not generate methods such as Resolve
1805
-
.Hint(Hint.Resolve, "Off")
1806
1799
.Bind().As(Singleton).To<Dependency>()
1807
1800
.Bind().To<Service>()
1808
1801
.Root<IService>("Root");
@@ -1863,8 +1856,6 @@ using Pure.DI;
1863
1856
usingstaticPure.DI.Lifetime;
1864
1857
1865
1858
DI.Setup(nameof(Composition))
1866
-
// This hint indicates to not generate methods such as Resolve
0 commit comments