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: AGENTS.md
+8-19Lines changed: 8 additions & 19 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2471,14 +2471,12 @@ To run the above code, the following NuGet packages must be added:
2471
2471
2472
2472
## Scope
2473
2473
2474
-
Demonstrates scoped lifetime with `Hint(Hint.ScopeFactory, "on")` where scopes are represented by generated `Scope` objects created via `CreateScope()`.
2475
-
2476
2474
```c#
2477
2475
usingShouldly;
2478
2476
usingPure.DI;
2479
2477
usingstaticPure.DI.Lifetime;
2480
2478
2481
-
varcomposition=newComposition(desc: "Checkout");
2479
+
varcomposition=newComposition();
2482
2480
IRequestContextctx1;
2483
2481
IRequestContextctx2;
2484
2482
@@ -2545,9 +2543,7 @@ interface ICheckoutService
2545
2543
2546
2544
// "Controller/service" that participates in request processing.
2547
2545
// It depends on a scoped context (per-request resource).
>This approach is useful when you need runtime scope creation without deriving a child composition type.
2593
-
2594
-
## Scope factory
2595
2586
2596
-
Demonstrates scoped lifetime with `Hint(Hint.ScopeFactory, "on")` where scopes are represented by generated `Scope` objects created via `CreateScope()`.
2587
+
## Scope setup method
2597
2588
2598
2589
```c#
2599
2590
usingShouldly;
@@ -2605,7 +2596,7 @@ IRequestContext ctx1;
2605
2596
IRequestContextctx2;
2606
2597
2607
2598
// Request #1
2608
-
using (varrequest1=composition.CreateScope())
2599
+
using (varrequest1=Composition.SetupScope(composition, newComposition()))
2609
2600
{
2610
2601
varcheckout11=request1.RequestRoot;
2611
2602
varcheckout12=request1.RequestRoot;
@@ -2620,7 +2611,7 @@ using (var request1 = composition.CreateScope())
2620
2611
ctx1.IsDisposed.ShouldBeTrue();
2621
2612
2622
2613
// Request #2
2623
-
using (varrequest2=composition.CreateScope())
2614
+
using (varrequest2=Composition.SetupScope(composition, newComposition()))
2624
2615
{
2625
2616
varcheckout2=request2.RequestRoot;
2626
2617
ctx2=checkout2.Context;
@@ -2678,7 +2669,7 @@ partial class Composition
2678
2669
staticvoidSetup() =>
2679
2670
2680
2671
DI.Setup()
2681
-
.Hint(Hint.ScopeFactoryName, "CreateScope")
2672
+
.Hint(Hint.ScopeMethodName, "SetupScope")
2682
2673
// Per-request lifetime
2683
2674
.Bind().As(Scoped).To<RequestContext>()
2684
2675
@@ -2696,8 +2687,6 @@ To run the above code, the following NuGet packages must be added:
Copy file name to clipboardExpand all lines: AGENTS_SMALL.md
+8-19Lines changed: 8 additions & 19 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1185,14 +1185,12 @@ To run the above code, the following NuGet packages must be added:
1185
1185
1186
1186
## Scope
1187
1187
1188
-
Demonstrates scoped lifetime with `Hint(Hint.ScopeFactory, "on")` where scopes are represented by generated `Scope` objects created via `CreateScope()`.
1189
-
1190
1188
```c#
1191
1189
usingShouldly;
1192
1190
usingPure.DI;
1193
1191
usingstaticPure.DI.Lifetime;
1194
1192
1195
-
varcomposition=newComposition(desc: "Checkout");
1193
+
varcomposition=newComposition();
1196
1194
IRequestContextctx1;
1197
1195
IRequestContextctx2;
1198
1196
@@ -1259,9 +1257,7 @@ interface ICheckoutService
1259
1257
1260
1258
// "Controller/service" that participates in request processing.
1261
1259
// It depends on a scoped context (per-request resource).
>This approach is useful when you need runtime scope creation without deriving a child composition type.
1307
-
1308
-
## Scope factory
1309
1300
1310
-
Demonstrates scoped lifetime with `Hint(Hint.ScopeFactory, "on")` where scopes are represented by generated `Scope` objects created via `CreateScope()`.
1301
+
## Scope setup method
1311
1302
1312
1303
```c#
1313
1304
usingShouldly;
@@ -1319,7 +1310,7 @@ IRequestContext ctx1;
1319
1310
IRequestContextctx2;
1320
1311
1321
1312
// Request #1
1322
-
using (varrequest1=composition.CreateScope())
1313
+
using (varrequest1=Composition.SetupScope(composition, newComposition()))
1323
1314
{
1324
1315
varcheckout11=request1.RequestRoot;
1325
1316
varcheckout12=request1.RequestRoot;
@@ -1334,7 +1325,7 @@ using (var request1 = composition.CreateScope())
1334
1325
ctx1.IsDisposed.ShouldBeTrue();
1335
1326
1336
1327
// Request #2
1337
-
using (varrequest2=composition.CreateScope())
1328
+
using (varrequest2=Composition.SetupScope(composition, newComposition()))
1338
1329
{
1339
1330
varcheckout2=request2.RequestRoot;
1340
1331
ctx2=checkout2.Context;
@@ -1392,7 +1383,7 @@ partial class Composition
1392
1383
staticvoidSetup() =>
1393
1384
1394
1385
DI.Setup()
1395
-
.Hint(Hint.ScopeFactoryName, "CreateScope")
1386
+
.Hint(Hint.ScopeMethodName, "SetupScope")
1396
1387
// Per-request lifetime
1397
1388
.Bind().As(Scoped).To<RequestContext>()
1398
1389
@@ -1410,8 +1401,6 @@ To run the above code, the following NuGet packages must be added:
0 commit comments