From b6f1c2c84e5abe7a1824fc767bb4ce7d69882201 Mon Sep 17 00:00:00 2001 From: Nikolay Pianikov Date: Tue, 19 Nov 2024 20:17:20 +0300 Subject: [PATCH] Update README.md --- readme/ArrayDetails.md | 21 +++++------- readme/EnumDetails.md | 21 +++++------- readme/FuncDetails.md | 5 +-- readme/SingletonDetails.md | 5 +-- readme/TransientDetails.md | 5 +-- readme/a-few-partial-classes.md | 12 +++---- readme/accumulators.md | 19 +++++------ readme/advanced-interception.md | 12 +++---- readme/array.md | 14 ++++---- readme/async-disposable-scope.md | 29 +++++++--------- readme/async-disposable-singleton.md | 12 +++---- readme/async-enumerable.md | 14 ++++---- readme/async-root.md | 27 ++++++--------- readme/auto-bindings.md | 5 +-- readme/auto-scoped.md | 24 +++++-------- readme/bind-attribute-for-a-generic-type.md | 6 ++-- .../bind-attribute-with-lifetime-and-tag.md | 10 +++--- readme/bind-attribute.md | 10 +++--- readme/build-up-of-an-existing-object.md | 20 +++++------ readme/check-for-a-root.md | 26 +++++++------- readme/class-arguments.md | 18 +++++----- readme/complex-generics.md | 5 +-- readme/composition-root-kinds.md | 12 +++---- readme/composition-roots.md | 8 ++--- readme/constructor-ordinal-attribute.md | 2 +- readme/custom-attributes.md | 18 +++++----- readme/custom-universal-attribute.md | 18 +++++----- readme/decorator.md | 8 ++--- .../default-lifetime-for-a-type-and-a-tag.md | 12 +++---- readme/default-lifetime-for-a-type.md | 12 +++---- readme/default-lifetime.md | 12 +++---- readme/default-values.md | 12 +++---- readme/dependent-compositions.md | 5 +-- readme/disposable-singleton.md | 12 +++---- readme/enumerable.md | 14 ++++---- readme/factory.md | 16 ++++----- readme/field-injection.md | 12 +++---- readme/func-with-arguments.md | 20 +++++------ readme/func-with-tag.md | 12 +++---- readme/func.md | 12 +++---- ...sync-composition-roots-with-constraints.md | 13 +++---- readme/inject-attribute.md | 6 ++-- readme/injections-of-abstractions.md | 15 ++++---- readme/keyed-service-provider.md | 12 +++---- readme/lazy.md | 12 +++---- readme/manually-started-tasks.md | 19 ++++------- readme/member-ordinal-attribute.md | 6 ++-- readme/method-injection.md | 12 +++---- readme/oncannotresolve-hint.md | 14 ++++---- readme/ondependencyinjection-hint.md | 12 +++---- readme/onnewinstance-hint.md | 18 +++++----- readme/overriding-the-bcl-binding.md | 2 +- readme/partial-class.md | 7 ++-- readme/perblock.md | 5 +-- readme/perresolve.md | 5 +-- readme/property-injection.md | 12 +++---- readme/required-properties-or-fields.md | 14 ++++---- readme/resolve-hint.md | 12 +++---- readme/resolve-methods.md | 16 ++++----- readme/root-arguments.md | 18 +++++----- readme/root-binding.md | 12 +++---- readme/scope.md | 27 +++++++-------- readme/service-collection.md | 12 +++---- readme/service-provider-with-scope.md | 12 +++---- readme/service-provider.md | 12 +++---- readme/simplified-binding.md | 12 +++---- readme/simplified-factory.md | 12 ++++--- readme/singleton.md | 12 +++---- readme/span-and-readonlyspan.md | 6 ++-- readme/tag-attribute.md | 12 +++---- readme/tag-on-a-constructor-argument.md | 18 +++++----- readme/tag-on-a-member.md | 12 +++---- readme/tag-on-a-method-argument.md | 12 +++---- .../tag-on-injection-site-with-wildcards.md | 24 ++++++------- readme/tag-on-injection-site.md | 18 +++++----- readme/tag-type.md | 10 +++--- readme/tags.md | 18 +++++----- readme/task.md | 25 ++++++-------- readme/threadsafe-hint.md | 34 +++++++++++++------ readme/tostring-hint.md | 12 +++---- ...async-disposable-instances-in-delegates.md | 16 ++++----- ...osable-instances-per-a-composition-root.md | 14 ++++---- ...cking-disposable-instances-in-delegates.md | 16 ++++----- ...osable-instances-per-a-composition-root.md | 14 ++++---- ...able-instances-with-different-lifetimes.md | 22 ++++++------ readme/transient.md | 12 +++---- readme/tuple.md | 18 +++++----- readme/type-attribute.md | 10 +++--- readme/valuetask.md | 12 +++---- readme/weak-reference.md | 14 ++++---- .../Hints/CheckForRootScenario.cs | 8 ++--- .../Hints/OnNewInstanceHintScenario.cs | 6 ++-- .../Hints/ThreadSafeHintScenario.cs | 4 +-- 93 files changed, 595 insertions(+), 650 deletions(-) diff --git a/readme/ArrayDetails.md b/readme/ArrayDetails.md index a3e2feda..6fff728f 100644 --- a/readme/ArrayDetails.md +++ b/readme/ArrayDetails.md @@ -13,9 +13,6 @@ classDiagram + object Resolve(Type type) + object Resolve(Type type, object? tag) } - class CompositionRoot { - +CompositionRoot(IService1 service1, IService2 service21, IService2 service22, IService2 service23, IService3 service3, IService4 service41, IService4 service42) - } Service1 --|> IService1 class Service1 { +Service1(IService2 service2) @@ -28,6 +25,11 @@ classDiagram class Service3 { +Service3(IService4 service41, IService4 service42) } + Service4 --|> IService4 + class Service4 { + +Service4() + } + class ArrayᐸIService3ᐳ Service3v2 --|> IService3 : 2 class Service3v2 { +Service3v2(IService4 service41, IService4 service42) @@ -40,11 +42,6 @@ classDiagram class Service3v4 { +Service3v4(IService4 service41, IService4 service42) } - Service4 --|> IService4 - class Service4 { - +Service4() - } - class ArrayᐸIService3ᐳ class IService1 { <> } @@ -57,21 +54,21 @@ classDiagram class IService4 { <> } + Array ..> CompositionRoot : CompositionRoot TestPureDIByCR() CompositionRoot *-- Service1 : IService1 CompositionRoot *-- "3 " Service2Array : IService2 CompositionRoot *-- Service3 : IService3 CompositionRoot *-- "2 " Service4 : IService4 - Array ..> CompositionRoot : CompositionRoot TestPureDIByCR() Service1 *-- Service2Array : IService2 Service2Array *-- ArrayᐸIService3ᐳ : ArrayᐸIService3ᐳ Service3 *-- "2 " Service4 : IService4 - Service3v2 *-- "2 " Service4 : IService4 - Service3v3 *-- "2 " Service4 : IService4 - Service3v4 *-- "2 " Service4 : IService4 ArrayᐸIService3ᐳ *-- Service3 : IService3 ArrayᐸIService3ᐳ *-- Service3v2 : 2 IService3 ArrayᐸIService3ᐳ *-- Service3v3 : 3 IService3 ArrayᐸIService3ᐳ *-- Service3v4 : 4 IService3 + Service3v2 *-- "2 " Service4 : IService4 + Service3v3 *-- "2 " Service4 : IService4 + Service3v4 *-- "2 " Service4 : IService4 ``` ### Generated code diff --git a/readme/EnumDetails.md b/readme/EnumDetails.md index ddc5bf4a..de0e9064 100644 --- a/readme/EnumDetails.md +++ b/readme/EnumDetails.md @@ -13,9 +13,6 @@ classDiagram + object Resolve(Type type) + object Resolve(Type type, object? tag) } - class CompositionRoot { - +CompositionRoot(IService1 service1, IService2 service21, IService2 service22, IService2 service23, IService3 service3, IService4 service41, IService4 service42) - } Service1 --|> IService1 class Service1 { +Service1(IService2 service2) @@ -28,6 +25,11 @@ classDiagram class Service3 { +Service3(IService4 service41, IService4 service42) } + Service4 --|> IService4 + class Service4 { + +Service4() + } + class IEnumerableᐸIService3ᐳ Service3v2 --|> IService3 : 2 class Service3v2 { +Service3v2(IService4 service41, IService4 service42) @@ -40,11 +42,6 @@ classDiagram class Service3v4 { +Service3v4(IService4 service41, IService4 service42) } - Service4 --|> IService4 - class Service4 { - +Service4() - } - class IEnumerableᐸIService3ᐳ class IService1 { <> } @@ -57,21 +54,21 @@ classDiagram class IService4 { <> } + Enum ..> CompositionRoot : CompositionRoot TestPureDIByCR() CompositionRoot *-- Service1 : IService1 CompositionRoot *-- "3 " Service2Enum : IService2 CompositionRoot *-- Service3 : IService3 CompositionRoot *-- "2 " Service4 : IService4 - Enum ..> CompositionRoot : CompositionRoot TestPureDIByCR() Service1 *-- Service2Enum : IService2 Service2Enum o-- "PerBlock" IEnumerableᐸIService3ᐳ : IEnumerableᐸIService3ᐳ Service3 *-- "2 " Service4 : IService4 - Service3v2 *-- "2 " Service4 : IService4 - Service3v3 *-- "2 " Service4 : IService4 - Service3v4 *-- "2 " Service4 : IService4 IEnumerableᐸIService3ᐳ *-- Service3 : IService3 IEnumerableᐸIService3ᐳ *-- Service3v2 : 2 IService3 IEnumerableᐸIService3ᐳ *-- Service3v3 : 3 IService3 IEnumerableᐸIService3ᐳ *-- Service3v4 : 4 IService3 + Service3v2 *-- "2 " Service4 : IService4 + Service3v3 *-- "2 " Service4 : IService4 + Service3v4 *-- "2 " Service4 : IService4 ``` ### Generated code diff --git a/readme/FuncDetails.md b/readme/FuncDetails.md index 872afaf2..cd405952 100644 --- a/readme/FuncDetails.md +++ b/readme/FuncDetails.md @@ -13,9 +13,6 @@ classDiagram + object Resolve(Type type) + object Resolve(Type type, object? tag) } - class CompositionRoot { - +CompositionRoot(IService1 service1, IService2 service21, IService2 service22, IService2 service23, IService3 service3, IService4 service41, IService4 service42) - } Service1 --|> IService1 class Service1 { +Service1(IService2 service2) @@ -45,11 +42,11 @@ classDiagram class IService4 { <> } + Func ..> CompositionRoot : CompositionRoot TestPureDIByCR() CompositionRoot *-- Service1 : IService1 CompositionRoot *-- "3 " Service2Func : IService2 CompositionRoot *-- Service3 : IService3 CompositionRoot *-- "2 " Service4 : IService4 - Func ..> CompositionRoot : CompositionRoot TestPureDIByCR() Service1 *-- Service2Func : IService2 Service2Func o-- "PerBlock" FuncᐸIService3ᐳ : FuncᐸIService3ᐳ Service3 *-- "2 " Service4 : IService4 diff --git a/readme/SingletonDetails.md b/readme/SingletonDetails.md index 9a603ae5..00258ea0 100644 --- a/readme/SingletonDetails.md +++ b/readme/SingletonDetails.md @@ -13,9 +13,6 @@ classDiagram + object Resolve(Type type) + object Resolve(Type type, object? tag) } - class CompositionRoot { - +CompositionRoot(IService1 service1, IService2 service21, IService2 service22, IService2 service23, IService3 service3, IService4 service41, IService4 service42) - } Service1 --|> IService1 class Service1 { +Service1(IService2 service2) @@ -44,11 +41,11 @@ classDiagram class IService4 { <> } + Singleton ..> CompositionRoot : CompositionRoot TestPureDIByCR() CompositionRoot o-- "Scoped" Service1 : IService1 CompositionRoot *-- "3 " Service2 : IService2 CompositionRoot *-- Service3 : IService3 CompositionRoot o-- "2 Scoped" Service4 : IService4 - Singleton ..> CompositionRoot : CompositionRoot TestPureDIByCR() Service1 *-- Service2 : IService2 Service2 *-- "5 " Service3 : IService3 Service3 o-- "2 Scoped" Service4 : IService4 diff --git a/readme/TransientDetails.md b/readme/TransientDetails.md index a38a6d5f..c16258bb 100644 --- a/readme/TransientDetails.md +++ b/readme/TransientDetails.md @@ -13,9 +13,6 @@ classDiagram + object Resolve(Type type) + object Resolve(Type type, object? tag) } - class CompositionRoot { - +CompositionRoot(IService1 service1, IService2 service21, IService2 service22, IService2 service23, IService3 service3, IService4 service41, IService4 service42) - } Service1 --|> IService1 class Service1 { +Service1(IService2 service2) @@ -44,11 +41,11 @@ classDiagram class IService4 { <> } + Transient ..> CompositionRoot : CompositionRoot TestPureDIByCR() CompositionRoot *-- Service1 : IService1 CompositionRoot *-- "3 " Service2 : IService2 CompositionRoot *-- Service3 : IService3 CompositionRoot *-- "2 " Service4 : IService4 - Transient ..> CompositionRoot : CompositionRoot TestPureDIByCR() Service1 *-- Service2 : IService2 Service2 *-- "5 " Service3 : IService3 Service3 *-- "2 " Service4 : IService4 diff --git a/readme/a-few-partial-classes.md b/readme/a-few-partial-classes.md index 81749b83..ba7106cf 100644 --- a/readme/a-few-partial-classes.md +++ b/readme/a-few-partial-classes.md @@ -197,20 +197,20 @@ classDiagram + object Resolve(Type type) + object Resolve(Type type, object? tag) } - Dependency --|> IDependency - class Dependency { - +Dependency() - } Service --|> IService class Service { +Service(IDependency dependency) } - class IDependency { - <> + Dependency --|> IDependency + class Dependency { + +Dependency() } class IService { <> } + class IDependency { + <> + } Composition ..> Service : IService Root Service *-- Dependency : IDependency ``` diff --git a/readme/accumulators.md b/readme/accumulators.md index 50fa97f9..33d2b68b 100644 --- a/readme/accumulators.md +++ b/readme/accumulators.md @@ -237,11 +237,12 @@ classDiagram + object Resolve(Type type) + object Resolve(Type type, object? tag) } - class MyAccumulator - class ValueTupleᐸIServiceˏMyAccumulatorᐳ { - +ValueTuple(IService item1, MyAccumulator item2) + Service --|> IService + class Service { + +Service(IDependency dependency1, IDependency dependency2, IDependency dependency3) } - AbcDependency --|> IDependency + class MyAccumulator + AbcDependency --|> IDependency : typeof(Pure.DI.UsageTests.Advanced.AccumulatorScenario.AbcDependency) class AbcDependency { +AbcDependency() } @@ -249,19 +250,15 @@ classDiagram class XyzDependency { +XyzDependency() } - Service --|> IService - class Service { - +Service(IDependency dependency1, IDependency dependency2, IDependency dependency3) - } - class IDependency { + class IService { <> } - class IService { + class IDependency { <> } + Composition ..> ValueTupleᐸIServiceˏMyAccumulatorᐳ : ValueTupleᐸIServiceˏMyAccumulatorᐳ Root ValueTupleᐸIServiceˏMyAccumulatorᐳ *-- Service : IService ValueTupleᐸIServiceˏMyAccumulatorᐳ *-- MyAccumulator : MyAccumulator - Composition ..> ValueTupleᐸIServiceˏMyAccumulatorᐳ : ValueTupleᐸIServiceˏMyAccumulatorᐳ Root Service *-- AbcDependency : typeof(Pure.DI.UsageTests.Advanced.AccumulatorScenario.AbcDependency) IDependency Service o-- "Singleton" XyzDependency : typeof(Pure.DI.UsageTests.Advanced.AccumulatorScenario.XyzDependency) IDependency Service o-- "PerBlock" AbcDependency : IDependency diff --git a/readme/advanced-interception.md b/readme/advanced-interception.md index a2b0a294..4f6d38ff 100644 --- a/readme/advanced-interception.md +++ b/readme/advanced-interception.md @@ -155,20 +155,20 @@ classDiagram <> +IService Root } - Dependency --|> IDependency - class Dependency { - +Dependency() - } Service --|> IService class Service { +Service(IDependency dependency) } - class IDependency { - <> + Dependency --|> IDependency + class Dependency { + +Dependency() } class IService { <> } + class IDependency { + <> + } Composition ..> Service : IService Root Service *-- Dependency : IDependency ``` diff --git a/readme/array.md b/readme/array.md index e6ba6c46..425f9557 100644 --- a/readme/array.md +++ b/readme/array.md @@ -218,6 +218,11 @@ classDiagram + object Resolve(Type type) + object Resolve(Type type, object? tag) } + Service --|> IService + class Service { + +Service(ArrayᐸIDependencyᐳ dependencies) + } + class ArrayᐸIDependencyᐳ AbcDependency --|> IDependency class AbcDependency { +AbcDependency() @@ -226,15 +231,10 @@ classDiagram class XyzDependency { +XyzDependency() } - Service --|> IService - class Service { - +Service(ArrayᐸIDependencyᐳ dependencies) - } - class ArrayᐸIDependencyᐳ - class IDependency { + class IService { <> } - class IService { + class IDependency { <> } Composition ..> Service : IService Root diff --git a/readme/async-disposable-scope.md b/readme/async-disposable-scope.md index dd88c895..7027b013 100644 --- a/readme/async-disposable-scope.md +++ b/readme/async-disposable-scope.md @@ -139,8 +139,8 @@ partial class Composition: IDisposable, IAsyncDisposable Func perBlockFunc1 = new Func([MethodImpl(MethodImplOptions.AggressiveInlining)] () => { Composition transientComposition3 = this; - Session localValue71 = new Session(transientComposition3); - return localValue71; + Session localValue72 = new Session(transientComposition3); + return localValue72; }); return new Program(perBlockFunc1); } @@ -229,37 +229,34 @@ classDiagram } Composition --|> IDisposable Composition --|> IAsyncDisposable - class Session { - +Session(Composition composition) - } - class Program { - +Program(FuncᐸSessionᐳ sessionFactory) + Service --|> IService + class Service { + +Service(IDependency dependency) } + class FuncᐸSessionᐳ Dependency --|> IDependency Dependency --|> IAsyncDisposable class Dependency { +Dependency() } - Service --|> IService - class Service { - +Service(IDependency dependency) + class Session { + +Session(Composition composition) } class Composition - class FuncᐸSessionᐳ - class IDependency { + class IService { <> } - class IAsyncDisposable { + class IDependency { <> } - class IService { + class IAsyncDisposable { <> } - Session *-- Composition : Composition - Program o-- "PerBlock" FuncᐸSessionᐳ : FuncᐸSessionᐳ Composition ..> Program : Program ProgramRoot Composition ..> Service : IService SessionRoot + Program o-- "PerBlock" FuncᐸSessionᐳ : FuncᐸSessionᐳ Service o-- "Scoped" Dependency : IDependency FuncᐸSessionᐳ *-- Session : Session + Session *-- Composition : Composition ``` diff --git a/readme/async-disposable-singleton.md b/readme/async-disposable-singleton.md index 375b9b55..4b75ce95 100644 --- a/readme/async-disposable-singleton.md +++ b/readme/async-disposable-singleton.md @@ -179,14 +179,17 @@ classDiagram } Composition --|> IDisposable Composition --|> IAsyncDisposable + Service --|> IService + class Service { + +Service(IDependency dependency) + } Dependency --|> IDependency Dependency --|> IAsyncDisposable class Dependency { +Dependency() } - Service --|> IService - class Service { - +Service(IDependency dependency) + class IService { + <> } class IDependency { <> @@ -194,9 +197,6 @@ classDiagram class IAsyncDisposable { <> } - class IService { - <> - } Composition ..> Service : IService Root Service o-- "Singleton" Dependency : IDependency ``` diff --git a/readme/async-enumerable.md b/readme/async-enumerable.md index 8917b73e..8cda93d2 100644 --- a/readme/async-enumerable.md +++ b/readme/async-enumerable.md @@ -210,6 +210,11 @@ classDiagram + object Resolve(Type type) + object Resolve(Type type, object? tag) } + Service --|> IService + class Service { + +Service(IAsyncEnumerableᐸIDependencyᐳ dependencies) + } + class IAsyncEnumerableᐸIDependencyᐳ AbcDependency --|> IDependency class AbcDependency { +AbcDependency() @@ -218,15 +223,10 @@ classDiagram class XyzDependency { +XyzDependency() } - Service --|> IService - class Service { - +Service(IAsyncEnumerableᐸIDependencyᐳ dependencies) - } - class IAsyncEnumerableᐸIDependencyᐳ - class IDependency { + class IService { <> } - class IService { + class IDependency { <> } Composition ..> Service : IService Root diff --git a/readme/async-root.md b/readme/async-root.md index feaba8a8..77226925 100644 --- a/readme/async-root.md +++ b/readme/async-root.md @@ -84,33 +84,27 @@ classDiagram <> +TaskᐸIServiceᐳ GetMyServiceAsync(System.Threading.CancellationToken cancellationToken) } - class TaskScheduler + class FuncᐸIServiceᐳ + class TaskFactoryᐸIServiceᐳ + Service --|> IService + class Service { + +Service(IDependency dependency) + } + class CancellationToken class TaskCreationOptions class TaskContinuationOptions - class TaskFactory + class TaskScheduler Dependency --|> IDependency class Dependency { +Dependency() } - Service --|> IService - class Service { - +Service(IDependency dependency) - } - class CancellationToken - class FuncᐸIServiceᐳ - class TaskFactoryᐸIServiceᐳ - class IDependency { + class IService { <> } - class IService { + class IDependency { <> } Composition ..> TaskᐸIServiceᐳ : TaskᐸIServiceᐳ GetMyServiceAsync(System.Threading.CancellationToken cancellationToken) - TaskFactory o-- CancellationToken : Argument "cancellationToken" - TaskFactory *-- TaskCreationOptions : TaskCreationOptions - TaskFactory *-- TaskContinuationOptions : TaskContinuationOptions - TaskFactory *-- TaskScheduler : TaskScheduler - Service *-- Dependency : IDependency TaskᐸIServiceᐳ o-- "PerBlock" FuncᐸIServiceᐳ : FuncᐸIServiceᐳ TaskᐸIServiceᐳ o-- "PerBlock" TaskFactoryᐸIServiceᐳ : TaskFactoryᐸIServiceᐳ FuncᐸIServiceᐳ *-- Service : IService @@ -118,5 +112,6 @@ classDiagram TaskFactoryᐸIServiceᐳ *-- TaskCreationOptions : TaskCreationOptions TaskFactoryᐸIServiceᐳ *-- TaskContinuationOptions : TaskContinuationOptions TaskFactoryᐸIServiceᐳ *-- TaskScheduler : TaskScheduler + Service *-- Dependency : IDependency ``` diff --git a/readme/auto-bindings.md b/readme/auto-bindings.md index b5d49d25..f8abb657 100644 --- a/readme/auto-bindings.md +++ b/readme/auto-bindings.md @@ -66,10 +66,7 @@ classDiagram class Dependency { +Dependency() } - class Service { - +Service(Dependency dependency) - } - Service *-- Dependency : Dependency Composition ..> Service : Service MyService + Service *-- Dependency : Dependency ``` diff --git a/readme/auto-scoped.md b/readme/auto-scoped.md index c9134d0c..f750b013 100644 --- a/readme/auto-scoped.md +++ b/readme/auto-scoped.md @@ -100,12 +100,12 @@ partial class Composition Composition transientComposition3 = this; IService transientIService2; // Injects a base composition - Composition localBaseComposition73 = transientComposition3; + Composition localBaseComposition74 = transientComposition3; // Creates a session - var localSession74= new Composition(localBaseComposition73); - transientIService2 = localSession74.SessionRoot; - IService localValue72 = transientIService2; - return localValue72; + var localSession75= new Composition(localBaseComposition74); + transientIService2 = localSession75.SessionRoot; + IService localValue73 = transientIService2; + return localValue73; }); return new Program(perBlockFunc1); } @@ -142,27 +142,21 @@ classDiagram +Program ProgramRoot +Service SessionRoot } - class Service { - +Service(IDependency dependency) - } - class Program { - +Program(FuncᐸIServiceᐳ serviceFactory) - } + class FuncᐸIServiceᐳ Dependency --|> IDependency class Dependency { +Dependency() } class IService - class FuncᐸIServiceᐳ class Composition class IDependency { <> } - Service o-- "Scoped" Dependency : IDependency - Program o-- "PerBlock" FuncᐸIServiceᐳ : FuncᐸIServiceᐳ Composition ..> Program : Program ProgramRoot Composition ..> Service : Service SessionRoot - IService *-- Composition : Composition + Program o-- "PerBlock" FuncᐸIServiceᐳ : FuncᐸIServiceᐳ + Service o-- "Scoped" Dependency : IDependency FuncᐸIServiceᐳ *-- IService : IService + IService *-- Composition : Composition ``` diff --git a/readme/bind-attribute-for-a-generic-type.md b/readme/bind-attribute-for-a-generic-type.md index ff18b412..44959119 100644 --- a/readme/bind-attribute-for-a-generic-type.md +++ b/readme/bind-attribute-for-a-generic-type.md @@ -100,14 +100,14 @@ classDiagram <> +IService Root } - class Facade { - +Facade() - } Service --|> IService class Service { +Service(IDependencyᐸInt32ᐳ dep) } class IDependencyᐸInt32ᐳ + class Facade { + +Facade() + } class IService { <> } diff --git a/readme/bind-attribute-with-lifetime-and-tag.md b/readme/bind-attribute-with-lifetime-and-tag.md index 0e4160ef..de417831 100644 --- a/readme/bind-attribute-with-lifetime-and-tag.md +++ b/readme/bind-attribute-with-lifetime-and-tag.md @@ -104,19 +104,19 @@ classDiagram <> +IService Root } - class IDependency - class Facade { - +Facade() - } Service --|> IService class Service { +Service(IDependency dep) } + class IDependency + class Facade { + +Facade() + } class IService { <> } Composition ..> Service : IService Root - IDependency o-- "Singleton" Facade : Facade Service o-- "Singleton" IDependency : "my tag" IDependency + IDependency o-- "Singleton" Facade : Facade ``` diff --git a/readme/bind-attribute.md b/readme/bind-attribute.md index 22ae6058..c3a2a8c5 100644 --- a/readme/bind-attribute.md +++ b/readme/bind-attribute.md @@ -104,19 +104,19 @@ classDiagram <> +IService Root } - class IDependency - class Facade { - +Facade() - } Service --|> IService class Service { +Service(IDependency dep) } + class IDependency + class Facade { + +Facade() + } class IService { <> } Composition ..> Service : IService Root - IDependency o-- "Singleton" Facade : Facade Service *-- IDependency : IDependency + IDependency o-- "Singleton" Facade : Facade ``` diff --git a/readme/build-up-of-an-existing-object.md b/readme/build-up-of-an-existing-object.md index ac55a508..c33f13c7 100644 --- a/readme/build-up-of-an-existing-object.md +++ b/readme/build-up-of-an-existing-object.md @@ -93,30 +93,30 @@ classDiagram <> +IService GetMyService(string name) } - class String - class Guid - Dependency --|> IDependency - class Dependency { - +String Name - +SetId(Guid id) : Void - } Service --|> IService Service --|> IEquatableᐸServiceᐳ class Service { +Service(IDependency Dependency) } - class IDependency { - <> + Dependency --|> IDependency + class Dependency { + +String Name + +SetId(Guid id) : Void } + class String + class Guid class IService { <> } class IEquatableᐸServiceᐳ { <> } + class IDependency { + <> + } Composition ..> Service : IService GetMyService(string name) + Service *-- Dependency : IDependency Dependency o-- String : Argument "name" Dependency *-- Guid : Guid - Service *-- Dependency : IDependency ``` diff --git a/readme/check-for-a-root.md b/readme/check-for-a-root.md index ac86118d..faf2abbd 100644 --- a/readme/check-for-a-root.md +++ b/readme/check-for-a-root.md @@ -17,7 +17,7 @@ interface IService class Service : IService { - [Tag("MyDep")] + [Tag("MyDepTag")] public required IDependency Dependency { get; init; } } @@ -34,11 +34,11 @@ partial class Composition // Specifies to use the partial OnNewRoot method // to register each root .Hint(Hint.OnNewRoot, "On") - .Bind("MyDep").To() + .Bind("MyDepTag").To() .Bind().To() // Composition roots - .Root(tag: "MyDep") + .Root(tag: "MyDepTag") .Root("Root"); // Adds a new root to the hash set @@ -51,7 +51,7 @@ partial class Composition } Composition.HasRoot(typeof(IService)).ShouldBeTrue(); -Composition.HasRoot(typeof(IDependency), "MyDep").ShouldBeTrue(); +Composition.HasRoot(typeof(IDependency), "MyDepTag").ShouldBeTrue(); Composition.HasRoot(typeof(IDependency)).ShouldBeFalse(); Composition.HasRoot(typeof(IComparable)).ShouldBeFalse(); @@ -167,7 +167,7 @@ partial class Composition OnNewRoot(valResolver_0000, "Root", null, Lifetime.Transient); Resolver.Value = valResolver_0000; var valResolver_0001 = new Resolver_0001(); - OnNewRoot(valResolver_0001, "Root2", "MyDep", Lifetime.Transient); + OnNewRoot(valResolver_0001, "Root2", "MyDepTag", Lifetime.Transient); Resolver.Value = valResolver_0001; _buckets = Buckets>.Create( 4, @@ -228,7 +228,7 @@ partial class Composition { switch (tag) { - case "MyDep": + case "MyDepTag": return composition.Root2; default: @@ -252,23 +252,23 @@ classDiagram + object Resolve(Type type) + object Resolve(Type type, object? tag) } - Dependency --|> IDependency : "MyDep" - class Dependency { - +Dependency() - } Service --|> IService class Service { +Service() +IDependency Dependency } - class IDependency { - <> + Dependency --|> IDependency : "MyDepTag" + class Dependency { + +Dependency() } class IService { <> } + class IDependency { + <> + } Composition ..> Service : IService Root Composition ..> Dependency : IDependency _ - Service *-- Dependency : "MyDep" IDependency + Service *-- Dependency : "MyDepTag" IDependency ``` diff --git a/readme/class-arguments.md b/readme/class-arguments.md index ceb73d97..ca3029cc 100644 --- a/readme/class-arguments.md +++ b/readme/class-arguments.md @@ -113,26 +113,26 @@ classDiagram <> +IService MyService } - Dependency --|> IDependency - class Dependency { - +Dependency(Int32 id, String name) - } Service --|> IService class Service { +Service(String name, IDependency dependency) } - class Int32 class String - class IDependency { - <> + Dependency --|> IDependency + class Dependency { + +Dependency(Int32 id, String name) } + class Int32 class IService { <> } + class IDependency { + <> + } Composition ..> Service : IService MyService - Dependency o-- Int32 : Argument "id" - Dependency o-- String : Argument "dependencyName" Service o-- String : "my service name" Argument "serviceName" Service *-- Dependency : IDependency + Dependency o-- Int32 : Argument "id" + Dependency o-- String : Argument "dependencyName" ``` diff --git a/readme/complex-generics.md b/readme/complex-generics.md index 1e4de3d9..121a4a68 100644 --- a/readme/complex-generics.md +++ b/readme/complex-generics.md @@ -100,9 +100,6 @@ classDiagram <> +ProgramᐸStringᐳ Root } - class ProgramᐸStringᐳ { - +Program(IServiceᐸStringˏInt32ˏListᐸStringᐳˏDictionaryᐸStringˏInt32ᐳᐳ service) - } ServiceᐸStringˏInt32ˏListᐸStringᐳˏDictionaryᐸStringˏInt32ᐳᐳ --|> IServiceᐸStringˏInt32ˏListᐸStringᐳˏDictionaryᐸStringˏInt32ᐳᐳ class ServiceᐸStringˏInt32ˏListᐸStringᐳˏDictionaryᐸStringˏInt32ᐳᐳ { +Service(IDependencyᐸStringᐳ dependency1, IDependencyᐸInt32ᐳ dependency2) @@ -124,8 +121,8 @@ classDiagram class IDependencyᐸInt32ᐳ { <> } - ProgramᐸStringᐳ *-- ServiceᐸStringˏInt32ˏListᐸStringᐳˏDictionaryᐸStringˏInt32ᐳᐳ : IServiceᐸStringˏInt32ˏListᐸStringᐳˏDictionaryᐸStringˏInt32ᐳᐳ Composition ..> ProgramᐸStringᐳ : ProgramᐸStringᐳ Root + ProgramᐸStringᐳ *-- ServiceᐸStringˏInt32ˏListᐸStringᐳˏDictionaryᐸStringˏInt32ᐳᐳ : IServiceᐸStringˏInt32ˏListᐸStringᐳˏDictionaryᐸStringˏInt32ᐳᐳ ServiceᐸStringˏInt32ˏListᐸStringᐳˏDictionaryᐸStringˏInt32ᐳᐳ *-- DependencyᐸStringᐳ : IDependencyᐸStringᐳ ServiceᐸStringˏInt32ˏListᐸStringᐳˏDictionaryᐸStringˏInt32ᐳᐳ *-- DependencyStructᐸInt32ᐳ : "value type" IDependencyᐸInt32ᐳ ``` diff --git a/readme/composition-root-kinds.md b/readme/composition-root-kinds.md index c031ae45..587f8d3a 100644 --- a/readme/composition-root-kinds.md +++ b/readme/composition-root-kinds.md @@ -242,6 +242,10 @@ classDiagram + object Resolve(Type type) + object Resolve(Type type, object? tag) } + Dependency --|> IDependency + class Dependency { + +Dependency() + } Service --|> IService class Service { +Service(IDependency dependency) @@ -250,14 +254,10 @@ classDiagram class OtherService { +OtherService() } - Dependency --|> IDependency - class Dependency { - +Dependency() - } - class IService { + class IDependency { <> } - class IDependency { + class IService { <> } Composition ..> Dependency : IDependency Dependency diff --git a/readme/composition-roots.md b/readme/composition-roots.md index 7812f7f1..4747417e 100644 --- a/readme/composition-roots.md +++ b/readme/composition-roots.md @@ -274,10 +274,6 @@ classDiagram + object Resolve(Type type) + object Resolve(Type type, object? tag) } - Service --|> IService - class Service { - +Service(IDependency dependency) - } OtherService --|> IService : "Other" class OtherService { +OtherService() @@ -286,6 +282,10 @@ classDiagram class Dependency { +Dependency() } + Service --|> IService + class Service { + +Service(IDependency dependency) + } class IService { <> } diff --git a/readme/constructor-ordinal-attribute.md b/readme/constructor-ordinal-attribute.md index b8823f03..f9c50173 100644 --- a/readme/constructor-ordinal-attribute.md +++ b/readme/constructor-ordinal-attribute.md @@ -86,11 +86,11 @@ classDiagram <> +IService Root } - class String Service --|> IService class Service { ~Service(String name) } + class String class IService { <> } diff --git a/readme/custom-attributes.md b/readme/custom-attributes.md index e678a269..d931cfd6 100644 --- a/readme/custom-attributes.md +++ b/readme/custom-attributes.md @@ -114,18 +114,21 @@ classDiagram <> +IPerson Person } - class Int32 - Uri --|> ISpanFormattable - Uri --|> IFormattable - Uri --|> ISerializable - class Uri - class String Person --|> IPerson class Person { +Person(String name) ~Object Id +Initialize(Object state) : Void } + class String + class Int32 + Uri --|> ISpanFormattable + Uri --|> IFormattable + Uri --|> ISerializable + class Uri + class IPerson { + <> + } class ISpanFormattable { <> } @@ -135,9 +138,6 @@ classDiagram class ISerializable { <> } - class IPerson { - <> - } PersonComposition ..> Person : IPerson Person Person *-- String : "NikName" String Person o-- Int32 : Argument "personId" diff --git a/readme/custom-universal-attribute.md b/readme/custom-universal-attribute.md index d099c16d..d531dc15 100644 --- a/readme/custom-universal-attribute.md +++ b/readme/custom-universal-attribute.md @@ -91,18 +91,21 @@ classDiagram <> +IPerson Person } - class Int32 - Uri --|> ISpanFormattable - Uri --|> IFormattable - Uri --|> ISerializable - class Uri - class String Person --|> IPerson class Person { +Person(String name) ~Object Id +Initialize(Object state) : Void } + class String + class Int32 + Uri --|> ISpanFormattable + Uri --|> IFormattable + Uri --|> ISerializable + class Uri + class IPerson { + <> + } class ISpanFormattable { <> } @@ -112,9 +115,6 @@ classDiagram class ISerializable { <> } - class IPerson { - <> - } PersonComposition ..> Person : IPerson Person Person *-- String : "NikName" String Person o-- Int32 : Argument "personId" diff --git a/readme/decorator.md b/readme/decorator.md index 7c898524..6458a394 100644 --- a/readme/decorator.md +++ b/readme/decorator.md @@ -72,14 +72,14 @@ classDiagram <> +IService Root } - Service --|> IService : "base" - class Service { - +Service() - } GreetingService --|> IService class GreetingService { +GreetingService(IService baseService) } + Service --|> IService : "base" + class Service { + +Service() + } class IService { <> } diff --git a/readme/default-lifetime-for-a-type-and-a-tag.md b/readme/default-lifetime-for-a-type-and-a-tag.md index 1d9e7808..c9855cf1 100644 --- a/readme/default-lifetime-for-a-type-and-a-tag.md +++ b/readme/default-lifetime-for-a-type-and-a-tag.md @@ -110,20 +110,20 @@ classDiagram <> +IService Root } - Dependency --|> IDependency : "some tag" - class Dependency { - +Dependency() - } Service --|> IService class Service { +Service(IDependency dependency1, IDependency dependency2) } - class IDependency { - <> + Dependency --|> IDependency : "some tag" + class Dependency { + +Dependency() } class IService { <> } + class IDependency { + <> + } Composition ..> Service : IService Root Service o-- "Singleton" Dependency : "some tag" IDependency Service o-- "Singleton" Dependency : IDependency diff --git a/readme/default-lifetime-for-a-type.md b/readme/default-lifetime-for-a-type.md index 21649b9d..e54f7010 100644 --- a/readme/default-lifetime-for-a-type.md +++ b/readme/default-lifetime-for-a-type.md @@ -97,20 +97,20 @@ classDiagram <> +IService Root } - Dependency --|> IDependency - class Dependency { - +Dependency() - } Service --|> IService class Service { +Service(IDependency dependency1, IDependency dependency2) } - class IDependency { - <> + Dependency --|> IDependency + class Dependency { + +Dependency() } class IService { <> } + class IDependency { + <> + } Composition ..> Service : IService Root Service o-- "2 Singleton" Dependency : IDependency ``` diff --git a/readme/default-lifetime.md b/readme/default-lifetime.md index f5a962db..95093419 100644 --- a/readme/default-lifetime.md +++ b/readme/default-lifetime.md @@ -105,20 +105,20 @@ classDiagram <> +IService Root } - Dependency --|> IDependency - class Dependency { - +Dependency() - } Service --|> IService class Service { +Service(IDependency dependency1, IDependency dependency2) } - class IDependency { - <> + Dependency --|> IDependency + class Dependency { + +Dependency() } class IService { <> } + class IDependency { + <> + } Composition ..> Service : IService Root Service o-- "2 Singleton" Dependency : IDependency ``` diff --git a/readme/default-values.md b/readme/default-values.md index 2f481c9f..3e24c2e2 100644 --- a/readme/default-values.md +++ b/readme/default-values.md @@ -74,21 +74,21 @@ classDiagram <> +IService Root } - Dependency --|> IDependency - class Dependency { - +Dependency() - } Service --|> IService class Service { +Service(String name) +IDependency Dependency } - class IDependency { - <> + Dependency --|> IDependency + class Dependency { + +Dependency() } class IService { <> } + class IDependency { + <> + } Composition ..> Service : IService Root Service *-- Dependency : IDependency ``` diff --git a/readme/dependent-compositions.md b/readme/dependent-compositions.md index d0c81448..24a491ab 100644 --- a/readme/dependent-compositions.md +++ b/readme/dependent-compositions.md @@ -377,9 +377,6 @@ classDiagram + object Resolve(Type type) + object Resolve(Type type, object? tag) } - class Program { - +Program(IService service) - } Service --|> IService class Service { +Service(IDependency dependency) @@ -394,9 +391,9 @@ classDiagram class IDependency { <> } - Program *-- Service : IService OtherComposition ..> Program : Program Program OtherComposition ..> Service : IService Root + Program *-- Service : IService Service *-- Dependency : IDependency ``` diff --git a/readme/disposable-singleton.md b/readme/disposable-singleton.md index 38353cbd..0aa2dd3e 100644 --- a/readme/disposable-singleton.md +++ b/readme/disposable-singleton.md @@ -139,20 +139,20 @@ classDiagram +IService Root } Composition --|> IDisposable - Dependency --|> IDependency - class Dependency { - +Dependency() - } Service --|> IService class Service { +Service(IDependency dependency) } - class IDependency { - <> + Dependency --|> IDependency + class Dependency { + +Dependency() } class IService { <> } + class IDependency { + <> + } Composition ..> Service : IService Root Service o-- "Singleton" Dependency : IDependency ``` diff --git a/readme/enumerable.md b/readme/enumerable.md index d64b4226..b6e20383 100644 --- a/readme/enumerable.md +++ b/readme/enumerable.md @@ -201,6 +201,11 @@ classDiagram + object Resolve(Type type) + object Resolve(Type type, object? tag) } + Service --|> IService + class Service { + +Service(IEnumerableᐸIDependencyᐳ dependencies) + } + class IEnumerableᐸIDependencyᐳ AbcDependency --|> IDependency class AbcDependency { +AbcDependency() @@ -209,15 +214,10 @@ classDiagram class XyzDependency { +XyzDependency() } - Service --|> IService - class Service { - +Service(IEnumerableᐸIDependencyᐳ dependencies) - } - class IEnumerableᐸIDependencyᐳ - class IDependency { + class IService { <> } - class IService { + class IDependency { <> } Composition ..> Service : IService Root diff --git a/readme/factory.md b/readme/factory.md index 33c8a943..4cd239e7 100644 --- a/readme/factory.md +++ b/readme/factory.md @@ -133,23 +133,23 @@ classDiagram <> +IService GetMyService(bool isFake) } - class Dependency { - +Dependency(DateTimeOffset time) - } - class DateTimeOffset - class Boolean - class IDependency Service --|> IService class Service { +Service(IDependency dependency) } + class IDependency + class Boolean + class Dependency { + +Dependency(DateTimeOffset time) + } + class DateTimeOffset class IService { <> } - Dependency *-- DateTimeOffset : DateTimeOffset Composition ..> Service : IService GetMyService(bool isFake) + Service *-- IDependency : IDependency IDependency o-- Boolean : "FakeArgTag" Argument "isFake" IDependency *-- Dependency : Dependency - Service *-- IDependency : IDependency + Dependency *-- DateTimeOffset : DateTimeOffset ``` diff --git a/readme/field-injection.md b/readme/field-injection.md index 539f7a4f..a4429bc8 100644 --- a/readme/field-injection.md +++ b/readme/field-injection.md @@ -76,21 +76,21 @@ classDiagram <> +IService MyService } - Dependency --|> IDependency - class Dependency { - +Dependency() - } Service --|> IService class Service { +Service() ~IDependency DependencyVal } - class IDependency { - <> + Dependency --|> IDependency + class Dependency { + +Dependency() } class IService { <> } + class IDependency { + <> + } Composition ..> Service : IService MyService Service *-- Dependency : IDependency ``` diff --git a/readme/func-with-arguments.md b/readme/func-with-arguments.md index cf9fccda..9e04c484 100644 --- a/readme/func-with-arguments.md +++ b/readme/func-with-arguments.md @@ -265,6 +265,11 @@ classDiagram + object Resolve(Type type) + object Resolve(Type type, object? tag) } + Service --|> IService + class Service { + +Service(FuncᐸInt32ˏInt32ˏIDependencyᐳ dependencyFactory) + } + class FuncᐸInt32ˏInt32ˏIDependencyᐳ class Dependency { +Dependency(IClock clock, Int32 id, Int32 subId) } @@ -273,22 +278,17 @@ classDiagram +Clock() } class Int32 - class FuncᐸInt32ˏInt32ˏIDependencyᐳ - Service --|> IService - class Service { - +Service(FuncᐸInt32ˏInt32ˏIDependencyᐳ dependencyFactory) - } - class IClock { + class IService { <> } - class IService { + class IClock { <> } + Composition ..> Service : IService Root + Service *-- FuncᐸInt32ˏInt32ˏIDependencyᐳ : FuncᐸInt32ˏInt32ˏIDependencyᐳ + FuncᐸInt32ˏInt32ˏIDependencyᐳ *-- Dependency : Dependency Dependency o-- "Singleton" Clock : IClock Dependency *-- Int32 : Int32 Dependency *-- Int32 : "sub" Int32 - Composition ..> Service : IService Root - FuncᐸInt32ˏInt32ˏIDependencyᐳ *-- Dependency : Dependency - Service *-- FuncᐸInt32ˏInt32ˏIDependencyᐳ : FuncᐸInt32ˏInt32ˏIDependencyᐳ ``` diff --git a/readme/func-with-tag.md b/readme/func-with-tag.md index d40a5697..972a272c 100644 --- a/readme/func-with-tag.md +++ b/readme/func-with-tag.md @@ -196,21 +196,21 @@ classDiagram + object Resolve(Type type) + object Resolve(Type type, object? tag) } - Dependency --|> IDependency : "my tag" - class Dependency { - +Dependency() - } Service --|> IService class Service { +Service(FuncᐸIDependencyᐳ dependencyFactory) } class FuncᐸIDependencyᐳ - class IDependency { - <> + Dependency --|> IDependency : "my tag" + class Dependency { + +Dependency() } class IService { <> } + class IDependency { + <> + } Composition ..> Service : IService Root Service o-- "PerBlock" FuncᐸIDependencyᐳ : "my tag" FuncᐸIDependencyᐳ FuncᐸIDependencyᐳ *-- Dependency : "my tag" IDependency diff --git a/readme/func.md b/readme/func.md index 53556788..c7d607eb 100644 --- a/readme/func.md +++ b/readme/func.md @@ -199,21 +199,21 @@ classDiagram + object Resolve(Type type) + object Resolve(Type type, object? tag) } - Dependency --|> IDependency - class Dependency { - +Dependency() - } Service --|> IService class Service { +Service(FuncᐸIDependencyᐳ dependencyFactory) } class FuncᐸIDependencyᐳ - class IDependency { - <> + Dependency --|> IDependency + class Dependency { + +Dependency() } class IService { <> } + class IDependency { + <> + } Composition ..> Service : IService Root Service o-- "PerBlock" FuncᐸIDependencyᐳ : FuncᐸIDependencyᐳ FuncᐸIDependencyᐳ *-- Dependency : IDependency diff --git a/readme/generic-async-composition-roots-with-constraints.md b/readme/generic-async-composition-roots-with-constraints.md index 46a8b851..e3344c17 100644 --- a/readme/generic-async-composition-roots-with-constraints.md +++ b/readme/generic-async-composition-roots-with-constraints.md @@ -151,17 +151,16 @@ classDiagram +TaskᐸIServiceᐸTˏT1ᐳᐳ GetMyRootAsyncᐸTˏT1ᐳ(System.Threading.CancellationToken cancellationToken) +TaskᐸIServiceᐸTˏBooleanᐳᐳ GetOtherServiceAsyncᐸTᐳ(System.Threading.CancellationToken cancellationToken) } - class TaskScheduler - class TaskCreationOptions - class TaskContinuationOptions - class TaskFactory - class CancellationToken class FuncᐸIServiceᐸTˏBooleanᐳᐳ class TaskFactoryᐸIServiceᐸTˏBooleanᐳᐳ class FuncᐸIServiceᐸTˏT1ᐳᐳ class TaskFactoryᐸIServiceᐸTˏT1ᐳᐳ OtherServiceᐸTᐳ --|> IServiceᐸTˏBooleanᐳ : "Other" class OtherServiceᐸTᐳ + class CancellationToken + class TaskCreationOptions + class TaskContinuationOptions + class TaskScheduler ServiceᐸTˏT1ᐳ --|> IServiceᐸTˏT1ᐳ class ServiceᐸTˏT1ᐳ { +Service(IDependencyᐸTᐳ dependency) @@ -181,10 +180,6 @@ classDiagram } Composition ..> TaskᐸIServiceᐸTˏBooleanᐳᐳ : TaskᐸIServiceᐸTˏBooleanᐳᐳ GetOtherServiceAsyncᐸTᐳ(System.Threading.CancellationToken cancellationToken) Composition ..> TaskᐸIServiceᐸTˏT1ᐳᐳ : TaskᐸIServiceᐸTˏT1ᐳᐳ GetMyRootAsyncᐸTˏT1ᐳ(System.Threading.CancellationToken cancellationToken) - TaskFactory o-- CancellationToken : Argument "cancellationToken" - TaskFactory *-- TaskCreationOptions : TaskCreationOptions - TaskFactory *-- TaskContinuationOptions : TaskContinuationOptions - TaskFactory *-- TaskScheduler : TaskScheduler TaskᐸIServiceᐸTˏBooleanᐳᐳ o-- "PerBlock" FuncᐸIServiceᐸTˏBooleanᐳᐳ : "Other" FuncᐸIServiceᐸTˏBooleanᐳᐳ TaskᐸIServiceᐸTˏBooleanᐳᐳ o-- "PerBlock" TaskFactoryᐸIServiceᐸTˏBooleanᐳᐳ : TaskFactoryᐸIServiceᐸTˏBooleanᐳᐳ TaskᐸIServiceᐸTˏT1ᐳᐳ o-- "PerBlock" FuncᐸIServiceᐸTˏT1ᐳᐳ : FuncᐸIServiceᐸTˏT1ᐳᐳ diff --git a/readme/inject-attribute.md b/readme/inject-attribute.md index c500bd87..f5ca627a 100644 --- a/readme/inject-attribute.md +++ b/readme/inject-attribute.md @@ -90,15 +90,15 @@ classDiagram <> +IPerson Person } - class Int32 - class Uri - class String Person --|> IPerson class Person { +Person(String name) ~Object Id +Initialize(Object state) : Void } + class String + class Int32 + class Uri class IPerson { <> } diff --git a/readme/injections-of-abstractions.md b/readme/injections-of-abstractions.md index 439098bf..0bb3e816 100644 --- a/readme/injections-of-abstractions.md +++ b/readme/injections-of-abstractions.md @@ -86,25 +86,22 @@ classDiagram <> +Program Root } - class Program { - +Program(IService service) + Service --|> IService + class Service { + +Service(IDependency dependency) } Dependency --|> IDependency class Dependency { +Dependency() } - Service --|> IService - class Service { - +Service(IDependency dependency) - } - class IDependency { + class IService { <> } - class IService { + class IDependency { <> } - Program *-- Service : IService Composition ..> Program : Program Root + Program *-- Service : IService Service *-- Dependency : IDependency ``` diff --git a/readme/keyed-service-provider.md b/readme/keyed-service-provider.md index b3f2f350..e4740ce0 100644 --- a/readme/keyed-service-provider.md +++ b/readme/keyed-service-provider.md @@ -260,20 +260,20 @@ classDiagram + object GetService(Type type) + object GetRequiredKeyedService(Type type, object? tag) } - Dependency --|> IDependency : "Dependency Key" - class Dependency { - +Dependency() - } Service --|> IService : "Service Key" class Service { +Service(IDependency dependency) } - class IDependency { - <> + Dependency --|> IDependency : "Dependency Key" + class Dependency { + +Dependency() } class IService { <> } + class IDependency { + <> + } Composition ..> Service : IService _ Composition ..> Dependency : IDependency _ Service o-- "Singleton" Dependency : "Dependency Key" IDependency diff --git a/readme/lazy.md b/readme/lazy.md index 749365d4..8183479c 100644 --- a/readme/lazy.md +++ b/readme/lazy.md @@ -195,22 +195,22 @@ classDiagram + object Resolve(Type type) + object Resolve(Type type, object? tag) } - Dependency --|> IDependency - class Dependency { - +Dependency() - } Service --|> IService class Service { +Service(LazyᐸIDependencyᐳ dependency) } class LazyᐸIDependencyᐳ class FuncᐸIDependencyᐳ - class IDependency { - <> + Dependency --|> IDependency + class Dependency { + +Dependency() } class IService { <> } + class IDependency { + <> + } Composition ..> Service : IService Root Service *-- LazyᐸIDependencyᐳ : LazyᐸIDependencyᐳ LazyᐸIDependencyᐳ o-- "PerBlock" FuncᐸIDependencyᐳ : FuncᐸIDependencyᐳ diff --git a/readme/manually-started-tasks.md b/readme/manually-started-tasks.md index 0aa7c06f..e36f25b4 100644 --- a/readme/manually-started-tasks.md +++ b/readme/manually-started-tasks.md @@ -113,29 +113,24 @@ classDiagram <> +IService GetRoot(System.Threading.CancellationToken cancellationToken) } - class TaskFactory - class CancellationToken - Dependency --|> IDependency - class Dependency { - +Dependency() - } Service --|> IService class Service { +Service(TaskᐸIDependencyᐳ dependencyTask) } class TaskᐸIDependencyᐳ class FuncᐸIDependencyᐳ - class IDependency { - <> + class CancellationToken + Dependency --|> IDependency + class Dependency { + +Dependency() } class IService { <> } + class IDependency { + <> + } Composition ..> Service : IService GetRoot(System.Threading.CancellationToken cancellationToken) - TaskFactory o-- CancellationToken : Argument "cancellationToken" - TaskFactory *-- TaskCreationOptions : TaskCreationOptions - TaskFactory *-- TaskContinuationOptions : TaskContinuationOptions - TaskFactory *-- TaskScheduler : TaskScheduler Service *-- TaskᐸIDependencyᐳ : TaskᐸIDependencyᐳ TaskᐸIDependencyᐳ o-- "PerBlock" FuncᐸIDependencyᐳ : FuncᐸIDependencyᐳ TaskᐸIDependencyᐳ o-- CancellationToken : Argument "cancellationToken" diff --git a/readme/member-ordinal-attribute.md b/readme/member-ordinal-attribute.md index fe0b4d85..722bf9f0 100644 --- a/readme/member-ordinal-attribute.md +++ b/readme/member-ordinal-attribute.md @@ -115,9 +115,6 @@ classDiagram <> +IPerson Person } - class Int32 - class String - class DateTime Person --|> IPerson class Person { +Person() @@ -125,6 +122,9 @@ classDiagram +String FirstName +DateTime Birthday } + class Int32 + class String + class DateTime class IPerson { <> } diff --git a/readme/method-injection.md b/readme/method-injection.md index 0711f740..f6edd695 100644 --- a/readme/method-injection.md +++ b/readme/method-injection.md @@ -78,21 +78,21 @@ classDiagram <> +IService MyService } - Dependency --|> IDependency - class Dependency { - +Dependency() - } Service --|> IService class Service { +Service() +SetDependency(IDependency dependency) : Void } - class IDependency { - <> + Dependency --|> IDependency + class Dependency { + +Dependency() } class IService { <> } + class IDependency { + <> + } Composition ..> Service : IService MyService Service *-- Dependency : IDependency ``` diff --git a/readme/oncannotresolve-hint.md b/readme/oncannotresolve-hint.md index 1db6428b..409a8e9a 100644 --- a/readme/oncannotresolve-hint.md +++ b/readme/oncannotresolve-hint.md @@ -99,23 +99,23 @@ classDiagram <> +IService Root } + Service --|> IService + class Service { + +Service(IDependency dependency) + } class String Dependency --|> IDependency class Dependency { +Dependency(String name) } - Service --|> IService - class Service { - +Service(IDependency dependency) - } - class IDependency { + class IService { <> } - class IService { + class IDependency { <> } Composition ..> Service : IService Root - Dependency *-- String : String Service *-- Dependency : IDependency + Dependency *-- String : String ``` diff --git a/readme/ondependencyinjection-hint.md b/readme/ondependencyinjection-hint.md index 698cd857..a9ba2cc7 100644 --- a/readme/ondependencyinjection-hint.md +++ b/readme/ondependencyinjection-hint.md @@ -97,20 +97,20 @@ classDiagram <> +IService Root } - Dependency --|> IDependency - class Dependency { - +Dependency() - } Service --|> IService class Service { +Service(IDependency dependency) } - class IDependency { - <> + Dependency --|> IDependency + class Dependency { + +Dependency() } class IService { <> } + class IDependency { + <> + } Composition ..> Service : IService Root Service *-- Dependency : IDependency ``` diff --git a/readme/onnewinstance-hint.md b/readme/onnewinstance-hint.md index babf2dc8..69a5e502 100644 --- a/readme/onnewinstance-hint.md +++ b/readme/onnewinstance-hint.md @@ -13,7 +13,7 @@ interface IDependency; class Dependency : IDependency { - public override string ToString() => "Dependency"; + public override string ToString() => nameof(Dependency); } interface IService @@ -25,7 +25,7 @@ class Service(IDependency dependency) : IService { public IDependency Dependency { get; } = dependency; - public override string ToString() => "Service"; + public override string ToString() => nameof(Service); } internal partial class Composition @@ -53,7 +53,7 @@ var composition = new Composition(log); var service1 = composition.Root; var service2 = composition.Root; -log.ShouldBe(ImmutableArray.Create("Dependency", "Service", "Service")); +log.ShouldBe([nameof(Dependency), nameof(Service), nameof(Service)]); ``` The `OnNewInstanceLifetimeRegularExpression` hint helps you define a set of lifetimes that require instance creation control. You can use it to specify a regular expression to filter bindings by lifetime name. @@ -121,20 +121,20 @@ classDiagram <> +IService Root } - Dependency --|> IDependency - class Dependency { - +Dependency() - } Service --|> IService class Service { +Service(IDependency dependency) } - class IDependency { - <> + Dependency --|> IDependency + class Dependency { + +Dependency() } class IService { <> } + class IDependency { + <> + } Composition ..> Service : IService Root Service o-- "Singleton" Dependency : IDependency ``` diff --git a/readme/overriding-the-bcl-binding.md b/readme/overriding-the-bcl-binding.md index 5526040b..286ecbdc 100644 --- a/readme/overriding-the-bcl-binding.md +++ b/readme/overriding-the-bcl-binding.md @@ -203,11 +203,11 @@ classDiagram + object Resolve(Type type) + object Resolve(Type type, object? tag) } - class ArrayᐸIDependencyᐳ Service --|> IService class Service { +Service(ArrayᐸIDependencyᐳ dependencies) } + class ArrayᐸIDependencyᐳ class IService { <> } diff --git a/readme/partial-class.md b/readme/partial-class.md index 304f4861..2e849e4d 100644 --- a/readme/partial-class.md +++ b/readme/partial-class.md @@ -224,21 +224,18 @@ classDiagram + object Resolve(Type type) + object Resolve(Type type, object? tag) } - class Service { - +Service(String name, IDependency dependency1, IDependency dependency2) - } + class String Dependency --|> IDependency class Dependency { +Dependency(Int64 id) } class Int64 - class String class IDependency { <> } + Composition ..> Service : Service Root Service *-- String : "name with id" String Service *-- "2 " Dependency : IDependency - Composition ..> Service : Service Root Dependency *-- Int64 : Int64 ``` diff --git a/readme/perblock.md b/readme/perblock.md index c7e6695b..3bdf62b7 100644 --- a/readme/perblock.md +++ b/readme/perblock.md @@ -102,9 +102,6 @@ classDiagram <> +Service Root } - class Service { - +Service(IDependency dep1, IDependency dep2, ValueTupleᐸIDependencyˏIDependencyᐳ deps) - } Dependency --|> IDependency class Dependency { +Dependency() @@ -115,9 +112,9 @@ classDiagram class IDependency { <> } + Composition ..> Service : Service Root Service o-- "2 PerBlock" Dependency : IDependency Service o-- "Singleton" ValueTupleᐸIDependencyˏIDependencyᐳ : ValueTupleᐸIDependencyˏIDependencyᐳ - Composition ..> Service : Service Root ValueTupleᐸIDependencyˏIDependencyᐳ o-- "2 PerBlock" Dependency : IDependency ``` diff --git a/readme/perresolve.md b/readme/perresolve.md index 1858401f..c85c9e5f 100644 --- a/readme/perresolve.md +++ b/readme/perresolve.md @@ -117,9 +117,6 @@ classDiagram <> +Service Root } - class Service { - +Service(IDependency dep1, IDependency dep2, ValueTupleᐸIDependencyˏIDependencyᐳ deps) - } Dependency --|> IDependency class Dependency { +Dependency() @@ -130,9 +127,9 @@ classDiagram class IDependency { <> } + Composition ..> Service : Service Root Service o-- "2 PerResolve" Dependency : IDependency Service o-- "Singleton" ValueTupleᐸIDependencyˏIDependencyᐳ : ValueTupleᐸIDependencyˏIDependencyᐳ - Composition ..> Service : Service Root ValueTupleᐸIDependencyˏIDependencyᐳ o-- "2 PerResolve" Dependency : IDependency ``` diff --git a/readme/property-injection.md b/readme/property-injection.md index 1e7ca5ce..ba152ead 100644 --- a/readme/property-injection.md +++ b/readme/property-injection.md @@ -75,21 +75,21 @@ classDiagram <> +IService MyService } - Dependency --|> IDependency - class Dependency { - +Dependency() - } Service --|> IService class Service { +Service() +IDependency Dependency } - class IDependency { - <> + Dependency --|> IDependency + class Dependency { + +Dependency() } class IService { <> } + class IDependency { + <> + } Composition ..> Service : IService MyService Service *-- Dependency : IDependency ``` diff --git a/readme/required-properties-or-fields.md b/readme/required-properties-or-fields.md index c7e0f3a7..1097d99d 100644 --- a/readme/required-properties-or-fields.md +++ b/readme/required-properties-or-fields.md @@ -83,23 +83,23 @@ classDiagram <> +IService Root } - class String - Dependency --|> IDependency - class Dependency { - +Dependency() - } Service --|> IService class Service { +Service() +String ServiceNameField +IDependency Dependency } - class IDependency { - <> + class String + Dependency --|> IDependency + class Dependency { + +Dependency() } class IService { <> } + class IDependency { + <> + } Composition ..> Service : IService Root Service o-- String : Argument "name" Service *-- Dependency : IDependency diff --git a/readme/resolve-hint.md b/readme/resolve-hint.md index cf7d2465..5fae0347 100644 --- a/readme/resolve-hint.md +++ b/readme/resolve-hint.md @@ -78,20 +78,20 @@ classDiagram +IDependency DependencyRoot +IService Root } - Dependency --|> IDependency - class Dependency { - +Dependency() - } Service --|> IService class Service { +Service(IDependency dependency) } - class IDependency { - <> + Dependency --|> IDependency + class Dependency { + +Dependency() } class IService { <> } + class IDependency { + <> + } Composition ..> Service : IService Root Composition ..> Dependency : IDependency DependencyRoot Service *-- Dependency : IDependency diff --git a/readme/resolve-methods.md b/readme/resolve-methods.md index 998c1e10..4a1799b1 100644 --- a/readme/resolve-methods.md +++ b/readme/resolve-methods.md @@ -219,22 +219,22 @@ classDiagram + object Resolve(Type type) + object Resolve(Type type, object? tag) } - Dependency --|> IDependency - class Dependency { - +Dependency() + OtherService --|> IService : "My Tag" + class OtherService { + +OtherService() } Service --|> IService class Service { +Service(IDependency dependency) } - OtherService --|> IService : "My Tag" - class OtherService { - +OtherService() + Dependency --|> IDependency + class Dependency { + +Dependency() } - class IDependency { + class IService { <> } - class IService { + class IDependency { <> } Composition ..> OtherService : IService OtherService diff --git a/readme/root-arguments.md b/readme/root-arguments.md index 03dbb45f..d1c00fe2 100644 --- a/readme/root-arguments.md +++ b/readme/root-arguments.md @@ -103,26 +103,26 @@ classDiagram <> +IService CreateServiceWithArgs(int id, string dependencyName, string serviceName) } - Dependency --|> IDependency - class Dependency { - +Dependency(Int32 id, String dependencyName) - } Service --|> IService class Service { +Service(String name, IDependency dependency) } - class Int32 class String - class IDependency { - <> + Dependency --|> IDependency + class Dependency { + +Dependency(Int32 id, String dependencyName) } + class Int32 class IService { <> } + class IDependency { + <> + } Composition ..> Service : IService CreateServiceWithArgs(int id, string dependencyName, string serviceName) - Dependency o-- Int32 : Argument "id" - Dependency o-- String : Argument "dependencyName" Service o-- String : "forService" Argument "serviceName" Service *-- Dependency : IDependency + Dependency o-- Int32 : Argument "id" + Dependency o-- String : Argument "dependencyName" ``` diff --git a/readme/root-binding.md b/readme/root-binding.md index 1ee313b7..8b5dd733 100644 --- a/readme/root-binding.md +++ b/readme/root-binding.md @@ -78,20 +78,20 @@ classDiagram <> +IService MyRoot } - Dependency --|> IDependency - class Dependency { - +Dependency() - } Service --|> IService class Service { +Service(IDependency dependency) } - class IDependency { - <> + Dependency --|> IDependency + class Dependency { + +Dependency() } class IService { <> } + class IDependency { + <> + } Composition ..> Service : IService MyRoot Service o-- "Singleton" Dependency : IDependency ``` diff --git a/readme/scope.md b/readme/scope.md index 975c9b1f..cfe927c0 100644 --- a/readme/scope.md +++ b/readme/scope.md @@ -137,8 +137,8 @@ partial class Composition: IDisposable Func perBlockFunc1 = new Func([MethodImpl(MethodImplOptions.AggressiveInlining)] () => { Composition transientComposition3 = this; - Session localValue75 = new Session(transientComposition3); - return localValue75; + Session localValue76 = new Session(transientComposition3); + return localValue76; }); return new Program(perBlockFunc1); } @@ -189,33 +189,30 @@ classDiagram +IService SessionRoot } Composition --|> IDisposable - class Session { - +Session(Composition composition) - } - class Program { - +Program(FuncᐸSessionᐳ sessionFactory) + Service --|> IService + class Service { + +Service(IDependency dependency) } + class FuncᐸSessionᐳ Dependency --|> IDependency class Dependency { +Dependency() } - Service --|> IService - class Service { - +Service(IDependency dependency) + class Session { + +Session(Composition composition) } class Composition - class FuncᐸSessionᐳ - class IDependency { + class IService { <> } - class IService { + class IDependency { <> } - Session *-- Composition : Composition - Program o-- "PerBlock" FuncᐸSessionᐳ : FuncᐸSessionᐳ Composition ..> Program : Program ProgramRoot Composition ..> Service : IService SessionRoot + Program o-- "PerBlock" FuncᐸSessionᐳ : FuncᐸSessionᐳ Service o-- "Scoped" Dependency : IDependency FuncᐸSessionᐳ *-- Session : Session + Session *-- Composition : Composition ``` diff --git a/readme/service-collection.md b/readme/service-collection.md index 1750fd2f..42a3e864 100644 --- a/readme/service-collection.md +++ b/readme/service-collection.md @@ -259,20 +259,20 @@ classDiagram + object Resolve(Type type) + object Resolve(Type type, object? tag) } - Dependency --|> IDependency : "Dependency Key" - class Dependency { - +Dependency() - } Service --|> IService class Service { +Service(IDependency dependency) } - class IDependency { - <> + Dependency --|> IDependency : "Dependency Key" + class Dependency { + +Dependency() } class IService { <> } + class IDependency { + <> + } Composition ..> Service : IService _ Composition ..> Dependency : IDependency _ Service o-- "Singleton" Dependency : "Dependency Key" IDependency diff --git a/readme/service-provider-with-scope.md b/readme/service-provider-with-scope.md index 4573726f..8197a63e 100644 --- a/readme/service-provider-with-scope.md +++ b/readme/service-provider-with-scope.md @@ -332,20 +332,20 @@ classDiagram + object GetRequiredKeyedService(Type type, object? tag) } Composition --|> IDisposable - Dependency --|> IDependency - class Dependency { - +Dependency() - } Service --|> IService class Service { +Service(IDependency dependency) } - class IDependency { - <> + Dependency --|> IDependency + class Dependency { + +Dependency() } class IService { <> } + class IDependency { + <> + } Composition ..> Service : IService _ Composition ..> Dependency : IDependency _ Service o-- "Singleton" Dependency : IDependency diff --git a/readme/service-provider.md b/readme/service-provider.md index ad6e11cb..178707f9 100644 --- a/readme/service-provider.md +++ b/readme/service-provider.md @@ -255,20 +255,20 @@ classDiagram + object GetService(Type type) + object Resolve(Type type, object? tag) } - Dependency --|> IDependency - class Dependency { - +Dependency() - } Service --|> IService class Service { +Service(IDependency dependency) } - class IDependency { - <> + Dependency --|> IDependency + class Dependency { + +Dependency() } class IService { <> } + class IDependency { + <> + } Composition ..> Service : IService _ Composition ..> Dependency : IDependency _ Service o-- "Singleton" Dependency : IDependency diff --git a/readme/simplified-binding.md b/readme/simplified-binding.md index 8ffba498..fc141763 100644 --- a/readme/simplified-binding.md +++ b/readme/simplified-binding.md @@ -131,15 +131,18 @@ classDiagram <> +IService MyService } + Service --|> IService + class Service { + +Service(Dependency dependencyImpl, IDependency dependency, IOtherDependency otherDependency) + } Dependency --|> IDependency Dependency --|> IOtherDependency Dependency --|> IEnumerableᐸStringᐳ class Dependency { +Dependency() } - Service --|> IService - class Service { - +Service(Dependency dependencyImpl, IDependency dependency, IOtherDependency otherDependency) + class IService { + <> } class IDependency { <> @@ -150,9 +153,6 @@ classDiagram class IEnumerableᐸStringᐳ { <> } - class IService { - <> - } Composition ..> Service : IService MyService Service o-- "PerBlock" Dependency : Dependency Service o-- "PerBlock" Dependency : IDependency diff --git a/readme/simplified-factory.md b/readme/simplified-factory.md index e57862e5..524c4a77 100644 --- a/readme/simplified-factory.md +++ b/readme/simplified-factory.md @@ -101,19 +101,21 @@ classDiagram <> +IService MyService } - class Dependency { - +Dependency() - } - class DateTimeOffset Service --|> IService class Service { +Service(IDependency dependency) } + Dependency --|> IDependency + class Dependency + class DateTimeOffset class IService { <> } + class IDependency { + <> + } Composition ..> Service : IService MyService - Dependency *-- DateTimeOffset : "now datetime" DateTimeOffset Service *-- Dependency : IDependency + Dependency *-- DateTimeOffset : "now datetime" DateTimeOffset ``` diff --git a/readme/singleton.md b/readme/singleton.md index fb3a0af9..a938d6d8 100644 --- a/readme/singleton.md +++ b/readme/singleton.md @@ -108,20 +108,20 @@ classDiagram <> +IService Root } - Dependency --|> IDependency - class Dependency { - +Dependency() - } Service --|> IService class Service { +Service(IDependency dependency1, IDependency dependency2) } - class IDependency { - <> + Dependency --|> IDependency + class Dependency { + +Dependency() } class IService { <> } + class IDependency { + <> + } Composition ..> Service : IService Root Service o-- "2 Singleton" Dependency : IDependency ``` diff --git a/readme/span-and-readonlyspan.md b/readme/span-and-readonlyspan.md index 3ca3a1cb..01747620 100644 --- a/readme/span-and-readonlyspan.md +++ b/readme/span-and-readonlyspan.md @@ -200,14 +200,14 @@ classDiagram + object Resolve(Type type) + object Resolve(Type type, object? tag) } - class Dependency { - +Dependency() - } Service --|> IService class Service { +Service(ReadOnlySpanᐸDependencyᐳ dependencies) } class ReadOnlySpanᐸDependencyᐳ + class Dependency { + +Dependency() + } class IService { <> } diff --git a/readme/tag-attribute.md b/readme/tag-attribute.md index a336d904..af9e4ed2 100644 --- a/readme/tag-attribute.md +++ b/readme/tag-attribute.md @@ -84,6 +84,10 @@ classDiagram <> +IService Root } + Service --|> IService + class Service { + +Service(IDependency dependency1, IDependency dependency2) + } AbcDependency --|> IDependency : "Abc" class AbcDependency { +AbcDependency() @@ -92,14 +96,10 @@ classDiagram class XyzDependency { +XyzDependency() } - Service --|> IService - class Service { - +Service(IDependency dependency1, IDependency dependency2) - } - class IDependency { + class IService { <> } - class IService { + class IDependency { <> } Composition ..> Service : IService Root diff --git a/readme/tag-on-a-constructor-argument.md b/readme/tag-on-a-constructor-argument.md index 7cc1998b..d068af1e 100644 --- a/readme/tag-on-a-constructor-argument.md +++ b/readme/tag-on-a-constructor-argument.md @@ -93,30 +93,30 @@ classDiagram <> +IService Root } - class ConsumerᐸStringᐳ { - +Consumer(IDependency myDep) + Service --|> IService + class Service { + +Service(IDependency dependency1, ConsumerᐸStringᐳ consumer) } AbcDependency --|> IDependency class AbcDependency { +AbcDependency() } + class ConsumerᐸStringᐳ { + +Consumer(IDependency myDep) + } XyzDependency --|> IDependency class XyzDependency { +XyzDependency() } - Service --|> IService - class Service { - +Service(IDependency dependency1, ConsumerᐸStringᐳ consumer) - } - class IDependency { + class IService { <> } - class IService { + class IDependency { <> } - ConsumerᐸStringᐳ *-- XyzDependency : IDependency Composition ..> Service : IService Root Service *-- AbcDependency : IDependency Service *-- ConsumerᐸStringᐳ : ConsumerᐸStringᐳ + ConsumerᐸStringᐳ *-- XyzDependency : IDependency ``` diff --git a/readme/tag-on-a-member.md b/readme/tag-on-a-member.md index 8e099ed3..47f573d3 100644 --- a/readme/tag-on-a-member.md +++ b/readme/tag-on-a-member.md @@ -79,21 +79,21 @@ classDiagram <> +IService Root } - XyzDependency --|> IDependency - class XyzDependency { - +XyzDependency() - } Service --|> IService class Service { +Service() +IDependency Dependency } - class IDependency { - <> + XyzDependency --|> IDependency + class XyzDependency { + +XyzDependency() } class IService { <> } + class IDependency { + <> + } Composition ..> Service : IService Root Service *-- XyzDependency : IDependency ``` diff --git a/readme/tag-on-a-method-argument.md b/readme/tag-on-a-method-argument.md index e848dfe8..d7a1a8ad 100644 --- a/readme/tag-on-a-method-argument.md +++ b/readme/tag-on-a-method-argument.md @@ -85,21 +85,21 @@ classDiagram <> +IService Root } - XyzDependency --|> IDependency - class XyzDependency { - +XyzDependency() - } Service --|> IService class Service { +Service() +Initialize(IDependency dep) : Void } - class IDependency { - <> + XyzDependency --|> IDependency + class XyzDependency { + +XyzDependency() } class IService { <> } + class IDependency { + <> + } Composition ..> Service : IService Root Service *-- XyzDependency : IDependency ``` diff --git a/readme/tag-on-injection-site-with-wildcards.md b/readme/tag-on-injection-site-with-wildcards.md index 36a0d4f9..d7474991 100644 --- a/readme/tag-on-injection-site-with-wildcards.md +++ b/readme/tag-on-injection-site-with-wildcards.md @@ -104,6 +104,15 @@ classDiagram <> +IService Root } + Service --|> IService + class Service { + +Service(IDependency dependency1, IDependency dependency2, ConsumerᐸStringᐳ consumer) + +IDependency Dependency3 + } + XyzDependency --|> IDependency + class XyzDependency { + +XyzDependency() + } class ConsumerᐸStringᐳ { +Consumer(IDependency myDep) } @@ -111,25 +120,16 @@ classDiagram class AbcDependency { +AbcDependency() } - XyzDependency --|> IDependency - class XyzDependency { - +XyzDependency() - } - Service --|> IService - class Service { - +Service(IDependency dependency1, IDependency dependency2, ConsumerᐸStringᐳ consumer) - +IDependency Dependency3 - } - class IDependency { + class IService { <> } - class IService { + class IDependency { <> } - ConsumerᐸStringᐳ *-- AbcDependency : IDependency Composition ..> Service : IService Root Service *-- "2 " XyzDependency : IDependency Service *-- ConsumerᐸStringᐳ : ConsumerᐸStringᐳ Service *-- AbcDependency : IDependency + ConsumerᐸStringᐳ *-- AbcDependency : IDependency ``` diff --git a/readme/tag-on-injection-site.md b/readme/tag-on-injection-site.md index b6235154..21e5b6be 100644 --- a/readme/tag-on-injection-site.md +++ b/readme/tag-on-injection-site.md @@ -91,8 +91,10 @@ classDiagram <> +IService Root } - class ConsumerᐸStringᐳ { - +Consumer(IDependency myDep) + Service --|> IService + class Service { + +Service(IDependency dependency1, IDependency dependency2, ConsumerᐸStringᐳ consumer) + +IDependency Dependency3 } AbcDependency --|> IDependency AbcDependency --|> IDependency @@ -103,21 +105,19 @@ classDiagram class XyzDependency { +XyzDependency() } - Service --|> IService - class Service { - +Service(IDependency dependency1, IDependency dependency2, ConsumerᐸStringᐳ consumer) - +IDependency Dependency3 + class ConsumerᐸStringᐳ { + +Consumer(IDependency myDep) } - class IDependency { + class IService { <> } - class IService { + class IDependency { <> } - ConsumerᐸStringᐳ *-- AbcDependency : IDependency Composition ..> Service : IService Root Service *-- AbcDependency : IDependency Service *-- "2 " XyzDependency : IDependency Service *-- ConsumerᐸStringᐳ : ConsumerᐸStringᐳ + ConsumerᐸStringᐳ *-- AbcDependency : IDependency ``` diff --git a/readme/tag-type.md b/readme/tag-type.md index a4643470..e9196a09 100644 --- a/readme/tag-type.md +++ b/readme/tag-type.md @@ -269,11 +269,6 @@ classDiagram + object Resolve(Type type) + object Resolve(Type type, object? tag) } - AbcDependency --|> IDependency : typeof(Pure.DI.UsageTests.Advanced.TagTypeScenario.AbcDependency) - AbcDependency --|> IDependency - class AbcDependency { - +AbcDependency() - } XyzDependency --|> IDependency : typeof(Pure.DI.UsageTests.Advanced.TagTypeScenario.XyzDependency) class XyzDependency { +XyzDependency() @@ -282,6 +277,11 @@ classDiagram class Service { +Service(IDependency dependency1, IDependency dependency2, IDependency dependency3) } + AbcDependency --|> IDependency : typeof(Pure.DI.UsageTests.Advanced.TagTypeScenario.AbcDependency) + AbcDependency --|> IDependency + class AbcDependency { + +AbcDependency() + } class IDependency { <> } diff --git a/readme/tags.md b/readme/tags.md index 155c9ae0..c28f0bc8 100644 --- a/readme/tags.md +++ b/readme/tags.md @@ -133,23 +133,23 @@ classDiagram +IService Root +IDependency XyzRoot } - AbcDependency --|> IDependency : "AbcTag" - AbcDependency --|> IDependency - class AbcDependency { - +AbcDependency() + Service --|> IService + class Service { + +Service(IDependency dependency1, IDependency dependency2, IDependency dependency3) } XyzDependency --|> IDependency : "XyzTag" class XyzDependency { +XyzDependency() } - Service --|> IService - class Service { - +Service(IDependency dependency1, IDependency dependency2, IDependency dependency3) + AbcDependency --|> IDependency : "AbcTag" + AbcDependency --|> IDependency + class AbcDependency { + +AbcDependency() } - class IDependency { + class IService { <> } - class IService { + class IDependency { <> } Composition ..> Service : IService Root diff --git a/readme/task.md b/readme/task.md index d3c3a72a..3098dbe8 100644 --- a/readme/task.md +++ b/readme/task.md @@ -113,15 +113,6 @@ classDiagram <> +IService GetRoot(System.Threading.CancellationToken cancellationToken) } - class TaskCreationOptions - class TaskContinuationOptions - class TaskFactory - class TaskScheduler - class CancellationToken - Dependency --|> IDependency - class Dependency { - +Dependency() - } Service --|> IService class Service { +Service(TaskᐸIDependencyᐳ dependencyTask) @@ -129,17 +120,21 @@ classDiagram class TaskᐸIDependencyᐳ class FuncᐸIDependencyᐳ class TaskFactoryᐸIDependencyᐳ - class IDependency { - <> + Dependency --|> IDependency + class Dependency { + +Dependency() } + class CancellationToken + class TaskCreationOptions + class TaskContinuationOptions + class TaskScheduler class IService { <> } + class IDependency { + <> + } Composition ..> Service : IService GetRoot(System.Threading.CancellationToken cancellationToken) - TaskFactory o-- CancellationToken : Argument "cancellationToken" - TaskFactory *-- TaskCreationOptions : TaskCreationOptions - TaskFactory *-- TaskContinuationOptions : TaskContinuationOptions - TaskFactory *-- TaskScheduler : TaskScheduler Service *-- TaskᐸIDependencyᐳ : TaskᐸIDependencyᐳ TaskᐸIDependencyᐳ o-- "PerBlock" FuncᐸIDependencyᐳ : FuncᐸIDependencyᐳ TaskᐸIDependencyᐳ o-- "PerBlock" TaskFactoryᐸIDependencyᐳ : TaskFactoryᐸIDependencyᐳ diff --git a/readme/threadsafe-hint.md b/readme/threadsafe-hint.md index 117af9ef..c051329c 100644 --- a/readme/threadsafe-hint.md +++ b/readme/threadsafe-hint.md @@ -15,12 +15,12 @@ class Dependency : IDependency; interface IService; -class Service(IDependency dependency) : IService; +class Service(Func dependencyFactory) : IService; DI.Setup(nameof(Composition)) .Hint(ThreadSafe, "Off") .Bind().To() - .Bind().To() + .Bind().As(Lifetime.Scoped).To() .Root("Root"); var composition = new Composition(); @@ -36,6 +36,8 @@ partial class Composition { private readonly Composition _root; + private Service? _scopedService40; + [OrdinalAttribute(20)] public Composition() { @@ -52,7 +54,17 @@ partial class Composition [MethodImpl(MethodImplOptions.AggressiveInlining)] get { - return new Service(new Dependency()); + if (_scopedService40 == null) + { + Func perBlockFunc0 = new Func([MethodImpl(MethodImplOptions.AggressiveInlining)] () => + { + IDependency localValue71 = new Dependency(); + return localValue71; + }); + _scopedService40 = new Service(perBlockFunc0); + } + + return _scopedService40!; } } } @@ -66,21 +78,23 @@ classDiagram <> +IService Root } + Service --|> IService + class Service { + +Service(FuncᐸIDependencyᐳ dependencyFactory) + } + class FuncᐸIDependencyᐳ Dependency --|> IDependency class Dependency { +Dependency() } - Service --|> IService - class Service { - +Service(IDependency dependency) - } - class IDependency { + class IService { <> } - class IService { + class IDependency { <> } Composition ..> Service : IService Root - Service *-- Dependency : IDependency + Service o-- "PerBlock" FuncᐸIDependencyᐳ : FuncᐸIDependencyᐳ + FuncᐸIDependencyᐳ *-- Dependency : IDependency ``` diff --git a/readme/tostring-hint.md b/readme/tostring-hint.md index f268a1cf..42f2027f 100644 --- a/readme/tostring-hint.md +++ b/readme/tostring-hint.md @@ -65,20 +65,20 @@ classDiagram <> +IService MyService } - Dependency --|> IDependency - class Dependency { - +Dependency() - } Service --|> IService class Service { +Service(IDependency dependency) } - class IDependency { - <> + Dependency --|> IDependency + class Dependency { + +Dependency() } class IService { <> } + class IDependency { + <> + } Composition ..> Service : IService MyService Service *-- Dependency : IDependency ``` diff --git a/readme/tracking-async-disposable-instances-in-delegates.md b/readme/tracking-async-disposable-instances-in-delegates.md index 7e48e88b..4caa1581 100644 --- a/readme/tracking-async-disposable-instances-in-delegates.md +++ b/readme/tracking-async-disposable-instances-in-delegates.md @@ -96,23 +96,23 @@ partial class Composition [MethodImpl(MethodImplOptions.AggressiveInlining)] get { - var accumulator41 = new Owned(); + var accumulator43 = new Owned(); Func> perBlockFunc1 = new Func>([MethodImpl(MethodImplOptions.AggressiveInlining)] () => { - var accumulator41 = new Owned(); + var accumulator43 = new Owned(); Dependency transientDependency4 = new Dependency(); lock (_lock) { - accumulator41.Add(transientDependency4); + accumulator43.Add(transientDependency4); } Owned perBlockOwned2; // Creates the owner of an instance - Owned localOwned8 = accumulator41; + Owned localOwned8 = accumulator43; IDependency localValue9 = transientDependency4; perBlockOwned2 = new Owned(localValue9, localOwned8); lock (_lock) { - accumulator41.Add(perBlockOwned2); + accumulator43.Add(perBlockOwned2); } Owned localValue7 = perBlockOwned2; return localValue7; @@ -120,7 +120,7 @@ partial class Composition Service transientService0 = new Service(perBlockFunc1); lock (_lock) { - accumulator41.Add(transientService0); + accumulator43.Add(transientService0); } return transientService0; } @@ -254,13 +254,13 @@ classDiagram + object Resolve(Type type) + object Resolve(Type type, object? tag) } + class FuncᐸOwnedᐸIDependencyᐳᐳ + class OwnedᐸIDependencyᐳ class Owned Dependency --|> IDependency class Dependency { +Dependency() } - class FuncᐸOwnedᐸIDependencyᐳᐳ - class OwnedᐸIDependencyᐳ class IDependency { <> } diff --git a/readme/tracking-async-disposable-instances-per-a-composition-root.md b/readme/tracking-async-disposable-instances-per-a-composition-root.md index eb1ac2aa..430bc0a7 100644 --- a/readme/tracking-async-disposable-instances-per-a-composition-root.md +++ b/readme/tracking-async-disposable-instances-per-a-composition-root.md @@ -165,14 +165,17 @@ classDiagram + object Resolve(Type type, object? tag) } class Owned + Service --|> IService + class Service { + +Service(IDependency dependency) + } Dependency --|> IDependency Dependency --|> IAsyncDisposable class Dependency { +Dependency() } - Service --|> IService - class Service { - +Service(IDependency dependency) + class IService { + <> } class IDependency { <> @@ -180,12 +183,9 @@ classDiagram class IAsyncDisposable { <> } - class IService { - <> - } Composition ..> OwnedᐸIServiceᐳ : OwnedᐸIServiceᐳ Root - Service *-- Dependency : IDependency OwnedᐸIServiceᐳ *-- Owned : Owned OwnedᐸIServiceᐳ *-- Service : IService + Service *-- Dependency : IDependency ``` diff --git a/readme/tracking-disposable-instances-in-delegates.md b/readme/tracking-disposable-instances-in-delegates.md index 8e8b47d1..d56f2b2f 100644 --- a/readme/tracking-disposable-instances-in-delegates.md +++ b/readme/tracking-disposable-instances-in-delegates.md @@ -89,23 +89,23 @@ partial class Composition [MethodImpl(MethodImplOptions.AggressiveInlining)] get { - var accumulator41 = new Owned(); + var accumulator43 = new Owned(); Func> perBlockFunc1 = new Func>([MethodImpl(MethodImplOptions.AggressiveInlining)] () => { - var accumulator41 = new Owned(); + var accumulator43 = new Owned(); Dependency transientDependency4 = new Dependency(); lock (_lock) { - accumulator41.Add(transientDependency4); + accumulator43.Add(transientDependency4); } Owned perBlockOwned2; // Creates the owner of an instance - Owned localOwned13 = accumulator41; + Owned localOwned13 = accumulator43; IDependency localValue14 = transientDependency4; perBlockOwned2 = new Owned(localValue14, localOwned13); lock (_lock) { - accumulator41.Add(perBlockOwned2); + accumulator43.Add(perBlockOwned2); } Owned localValue12 = perBlockOwned2; return localValue12; @@ -113,7 +113,7 @@ partial class Composition Service transientService0 = new Service(perBlockFunc1); lock (_lock) { - accumulator41.Add(transientService0); + accumulator43.Add(transientService0); } return transientService0; } @@ -247,13 +247,13 @@ classDiagram + object Resolve(Type type) + object Resolve(Type type, object? tag) } + class FuncᐸOwnedᐸIDependencyᐳᐳ + class OwnedᐸIDependencyᐳ class Owned Dependency --|> IDependency class Dependency { +Dependency() } - class FuncᐸOwnedᐸIDependencyᐳᐳ - class OwnedᐸIDependencyᐳ class IDependency { <> } diff --git a/readme/tracking-disposable-instances-per-a-composition-root.md b/readme/tracking-disposable-instances-per-a-composition-root.md index 55485170..ecc7526e 100644 --- a/readme/tracking-disposable-instances-per-a-composition-root.md +++ b/readme/tracking-disposable-instances-per-a-composition-root.md @@ -161,23 +161,23 @@ classDiagram + object Resolve(Type type, object? tag) } class Owned - Dependency --|> IDependency - class Dependency { - +Dependency() - } Service --|> IService class Service { +Service(IDependency dependency) } - class IDependency { - <> + Dependency --|> IDependency + class Dependency { + +Dependency() } class IService { <> } + class IDependency { + <> + } Composition ..> OwnedᐸIServiceᐳ : OwnedᐸIServiceᐳ Root - Service *-- Dependency : IDependency OwnedᐸIServiceᐳ *-- Owned : Owned OwnedᐸIServiceᐳ *-- Service : IService + Service *-- Dependency : IDependency ``` diff --git a/readme/tracking-disposable-instances-with-different-lifetimes.md b/readme/tracking-disposable-instances-with-different-lifetimes.md index 5199eae4..7ea2a0b4 100644 --- a/readme/tracking-disposable-instances-with-different-lifetimes.md +++ b/readme/tracking-disposable-instances-with-different-lifetimes.md @@ -119,10 +119,10 @@ partial class Composition: IDisposable [MethodImpl(MethodImplOptions.AggressiveInlining)] get { - var accumulator42 = new Owned(); + var accumulator46 = new Owned(); Func> perBlockFunc2 = new Func>([MethodImpl(MethodImplOptions.AggressiveInlining)] () => { - var accumulator42 = new Owned(); + var accumulator46 = new Owned(); if (_root._singletonDependency40 == null) { lock (_lock) @@ -137,32 +137,32 @@ partial class Composition: IDisposable Owned perBlockOwned3; // Creates the owner of an instance - Owned localOwned18 = accumulator42; + Owned localOwned18 = accumulator46; IDependency localValue19 = _root._singletonDependency40!; perBlockOwned3 = new Owned(localValue19, localOwned18); lock (_lock) { - accumulator42.Add(perBlockOwned3); + accumulator46.Add(perBlockOwned3); } Owned localValue17 = perBlockOwned3; return localValue17; }); Func> perBlockFunc1 = new Func>([MethodImpl(MethodImplOptions.AggressiveInlining)] () => { - var accumulator42 = new Owned(); + var accumulator46 = new Owned(); Dependency transientDependency7 = new Dependency(); lock (_lock) { - accumulator42.Add(transientDependency7); + accumulator46.Add(transientDependency7); } Owned perBlockOwned5; // Creates the owner of an instance - Owned localOwned21 = accumulator42; + Owned localOwned21 = accumulator46; IDependency localValue22 = transientDependency7; perBlockOwned5 = new Owned(localValue22, localOwned21); lock (_lock) { - accumulator42.Add(perBlockOwned5); + accumulator46.Add(perBlockOwned5); } Owned localValue20 = perBlockOwned5; return localValue20; @@ -170,7 +170,7 @@ partial class Composition: IDisposable Service transientService0 = new Service(perBlockFunc1, perBlockFunc2); lock (_lock) { - accumulator42.Add(transientService0); + accumulator46.Add(transientService0); } return transientService0; } @@ -338,13 +338,13 @@ classDiagram + object Resolve(Type type, object? tag) } Composition --|> IDisposable + class FuncᐸOwnedᐸIDependencyᐳᐳ + class OwnedᐸIDependencyᐳ class Owned Dependency --|> IDependency class Dependency { +Dependency() } - class FuncᐸOwnedᐸIDependencyᐳᐳ - class OwnedᐸIDependencyᐳ class IDependency { <> } diff --git a/readme/transient.md b/readme/transient.md index 5f580038..81bf108c 100644 --- a/readme/transient.md +++ b/readme/transient.md @@ -89,20 +89,20 @@ classDiagram <> +IService Root } - Dependency --|> IDependency - class Dependency { - +Dependency() - } Service --|> IService class Service { +Service(IDependency dependency1, IDependency dependency2) } - class IDependency { - <> + Dependency --|> IDependency + class Dependency { + +Dependency() } class IService { <> } + class IDependency { + <> + } Composition ..> Service : IService Root Service *-- "2 " Dependency : IDependency ``` diff --git a/readme/tuple.md b/readme/tuple.md index f3ac2d2e..288cef3d 100644 --- a/readme/tuple.md +++ b/readme/tuple.md @@ -190,27 +190,27 @@ classDiagram + object Resolve(Type type) + object Resolve(Type type, object? tag) } + Service --|> IService + class Service { + +Service(ValueTupleᐸPointˏIDependencyᐳ tuple) + } class ValueTupleᐸPointˏIDependencyᐳ { +ValueTuple(Point item1, IDependency item2) } + class Point Dependency --|> IDependency class Dependency { +Dependency() } - class Point - Service --|> IService - class Service { - +Service(ValueTupleᐸPointˏIDependencyᐳ tuple) - } - class IDependency { + class IService { <> } - class IService { + class IDependency { <> } - ValueTupleᐸPointˏIDependencyᐳ *-- Point : Point - ValueTupleᐸPointˏIDependencyᐳ *-- Dependency : IDependency Composition ..> Service : IService Root Service *-- ValueTupleᐸPointˏIDependencyᐳ : ValueTupleᐸPointˏIDependencyᐳ + ValueTupleᐸPointˏIDependencyᐳ *-- Point : Point + ValueTupleᐸPointˏIDependencyᐳ *-- Dependency : IDependency ``` diff --git a/readme/type-attribute.md b/readme/type-attribute.md index f59df46b..1eb940c7 100644 --- a/readme/type-attribute.md +++ b/readme/type-attribute.md @@ -80,15 +80,15 @@ classDiagram <> +IService Root } - class XyzDependency { - +XyzDependency() + Service --|> IService + class Service { + +Service(IDependency dependency1, IDependency dependency2) } class AbcDependency { +AbcDependency() } - Service --|> IService - class Service { - +Service(IDependency dependency1, IDependency dependency2) + class XyzDependency { + +XyzDependency() } class IService { <> diff --git a/readme/valuetask.md b/readme/valuetask.md index 2e7f4c39..2489b555 100644 --- a/readme/valuetask.md +++ b/readme/valuetask.md @@ -199,21 +199,21 @@ classDiagram + object Resolve(Type type) + object Resolve(Type type, object? tag) } - Dependency --|> IDependency - class Dependency { - +Dependency() - } Service --|> IService class Service { +Service(ValueTaskᐸIDependencyᐳ dependencyTask) } class ValueTaskᐸIDependencyᐳ - class IDependency { - <> + Dependency --|> IDependency + class Dependency { + +Dependency() } class IService { <> } + class IDependency { + <> + } Composition ..> Service : IService Root Service *-- ValueTaskᐸIDependencyᐳ : ValueTaskᐸIDependencyᐳ ValueTaskᐸIDependencyᐳ *-- Dependency : IDependency diff --git a/readme/weak-reference.md b/readme/weak-reference.md index b6f051f6..67760e8a 100644 --- a/readme/weak-reference.md +++ b/readme/weak-reference.md @@ -184,6 +184,10 @@ classDiagram + object Resolve(Type type) + object Resolve(Type type, object? tag) } + Service --|> IService + class Service { + +Service(WeakReferenceᐸIDependencyᐳ dependency) + } class WeakReferenceᐸIDependencyᐳ { +WeakReference(IDependency target) } @@ -191,18 +195,14 @@ classDiagram class Dependency { +Dependency() } - Service --|> IService - class Service { - +Service(WeakReferenceᐸIDependencyᐳ dependency) - } - class IDependency { + class IService { <> } - class IService { + class IDependency { <> } - WeakReferenceᐸIDependencyᐳ *-- Dependency : IDependency Composition ..> Service : IService Root Service *-- WeakReferenceᐸIDependencyᐳ : WeakReferenceᐸIDependencyᐳ + WeakReferenceᐸIDependencyᐳ *-- Dependency : IDependency ``` diff --git a/tests/Pure.DI.UsageTests/Hints/CheckForRootScenario.cs b/tests/Pure.DI.UsageTests/Hints/CheckForRootScenario.cs index a920d6c3..227ccf67 100644 --- a/tests/Pure.DI.UsageTests/Hints/CheckForRootScenario.cs +++ b/tests/Pure.DI.UsageTests/Hints/CheckForRootScenario.cs @@ -31,7 +31,7 @@ interface IService class Service : IService { - [Tag("MyDep")] + [Tag("MyDepTag")] public required IDependency Dependency { get; init; } } @@ -48,11 +48,11 @@ static void Setup() => // Specifies to use the partial OnNewRoot method // to register each root .Hint(Hint.OnNewRoot, "On") - .Bind("MyDep").To() + .Bind("MyDepTag").To() .Bind().To() // Composition roots - .Root(tag: "MyDep") + .Root(tag: "MyDepTag") .Root("Root"); // Adds a new root to the hash set @@ -72,7 +72,7 @@ public void Run() { // { Composition.HasRoot(typeof(IService)).ShouldBeTrue(); - Composition.HasRoot(typeof(IDependency), "MyDep").ShouldBeTrue(); + Composition.HasRoot(typeof(IDependency), "MyDepTag").ShouldBeTrue(); Composition.HasRoot(typeof(IDependency)).ShouldBeFalse(); Composition.HasRoot(typeof(IComparable)).ShouldBeFalse(); diff --git a/tests/Pure.DI.UsageTests/Hints/OnNewInstanceHintScenario.cs b/tests/Pure.DI.UsageTests/Hints/OnNewInstanceHintScenario.cs index f45ba434..9e8f0700 100644 --- a/tests/Pure.DI.UsageTests/Hints/OnNewInstanceHintScenario.cs +++ b/tests/Pure.DI.UsageTests/Hints/OnNewInstanceHintScenario.cs @@ -29,7 +29,7 @@ interface IDependency; class Dependency : IDependency { - public override string ToString() => "Dependency"; + public override string ToString() => nameof(Dependency); } interface IService @@ -41,7 +41,7 @@ class Service(IDependency dependency) : IService { public IDependency Dependency { get; } = dependency; - public override string ToString() => "Service"; + public override string ToString() => nameof(Service); } internal partial class Composition @@ -77,7 +77,7 @@ public void Run() var service1 = composition.Root; var service2 = composition.Root; - log.ShouldBe(ImmutableArray.Create("Dependency", "Service", "Service")); + log.ShouldBe([nameof(Dependency), nameof(Service), nameof(Service)]); // } composition.SaveClassDiagram(); } diff --git a/tests/Pure.DI.UsageTests/Hints/ThreadSafeHintScenario.cs b/tests/Pure.DI.UsageTests/Hints/ThreadSafeHintScenario.cs index f76eb153..88415426 100644 --- a/tests/Pure.DI.UsageTests/Hints/ThreadSafeHintScenario.cs +++ b/tests/Pure.DI.UsageTests/Hints/ThreadSafeHintScenario.cs @@ -28,7 +28,7 @@ class Dependency : IDependency; interface IService; -class Service(IDependency dependency) : IService; +class Service(Func dependencyFactory) : IService; // } public class Scenario @@ -41,7 +41,7 @@ public void Run() DI.Setup(nameof(Composition)) .Hint(ThreadSafe, "Off") .Bind().To() - .Bind().To() + .Bind().As(Lifetime.Scoped).To() .Root("Root"); var composition = new Composition();