Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
NikolayPianikov committed May 9, 2024
1 parent 1cb87d4 commit d43d711
Show file tree
Hide file tree
Showing 43 changed files with 99 additions and 1,319 deletions.
14 changes: 5 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,25 +197,18 @@ dotnet run
- [Auto-bindings](readme/auto-bindings.md)
- [Injections of abstractions](readme/injections-of-abstractions.md)
- [Composition roots](readme/composition-roots.md)
- [Composition roots simplified](readme/composition-roots-simplified.md)
- [Resolve methods](readme/resolve-methods.md)
- [Simplified binding](readme/simplified-binding.md)
- [Factory](readme/factory.md)
- [Injection](readme/injection.md)
- [Arguments](readme/arguments.md)
- [Root arguments](readme/root-arguments.md)
- [Tags](readme/tags.md)
- [Multi-contract bindings](readme/multi-contract-bindings.md)
- [Field injection](readme/field-injection.md)
- [Method injection](readme/method-injection.md)
- [Property injection](readme/property-injection.md)
- [Default values](readme/default-values.md)
- [Required properties or fields](readme/required-properties-or-fields.md)
- [Tracking async disposable instances in delegates](readme/tracking-async-disposable-instances-in-delegates.md)
- [Tracking disposable instances in delegates](readme/tracking-disposable-instances-in-delegates.md)
- [Tracking disposable instances per a composition root](readme/tracking-disposable-instances-per-a-composition-root.md)
- [RootBind](readme/rootbind.md)
- [Tracking async disposable instances per a composition root](readme/tracking-async-disposable-instances-per-a-composition-root.md)
- [Root binding](readme/root-binding.md)
### Lifetimes
- [Singleton](readme/singleton.md)
- [PerResolve](readme/perresolve.md)
Expand Down Expand Up @@ -272,14 +265,17 @@ dotnet run
- [Check for a root](readme/check-for-a-root.md)
### Advanced
- [Composition root kinds](readme/composition-root-kinds.md)
- [Instance Initialization](readme/instance-initialization.md)
- [Tag Type](readme/tag-type.md)
- [Tag Unique](readme/tag-unique.md)
- [A few partial classes](readme/a-few-partial-classes.md)
- [Partial class](readme/partial-class.md)
- [Dependent compositions](readme/dependent-compositions.md)
- [Accumulators](readme/accumulators.md)
- [Global compositions](readme/global-compositions.md)
- [Tracking async disposable instances in delegates](readme/tracking-async-disposable-instances-in-delegates.md)
- [Tracking disposable instances in delegates](readme/tracking-disposable-instances-in-delegates.md)
- [Tracking disposable instances per a composition root](readme/tracking-disposable-instances-per-a-composition-root.md)
- [Tracking async disposable instances per a composition root](readme/tracking-async-disposable-instances-per-a-composition-root.md)
### Applications
- Console
- [Schrödinger's cat](readme/Console.md)
Expand Down
269 changes: 0 additions & 269 deletions readme/composition-roots-simplified.md

This file was deleted.

26 changes: 14 additions & 12 deletions readme/composition-roots.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,18 @@ DI.Setup(nameof(Composition))
.Bind<IService>("Other").To<OtherService>()
.Bind<IDependency>().To<Dependency>()

// Specifies to create a regular public composition root
// of type "IService" with the name "SomeOtherService"
// using the "Other" tag
.Root<IService>("SomeOtherService", "Other")

// Specifies to create a regular public composition root
// of type "IService" with the name "MyRoot"
.Root<IService>("MyRoot")

// Specifies to create a private composition root
// that is only accessible from "Resolve()" methods
.Root<IDependency>();
.Root<IDependency>()

// Specifies to create a regular public composition root
// of type "IService" with the name "SomeOtherService"
// using the "Other" tag
.Root<IService>("SomeOtherService", "Other");

var composition = new Composition();

Expand All @@ -41,6 +41,8 @@ var service = composition.MyRoot;
// someOtherService = new OtherService();
var someOtherService = composition.SomeOtherService;

// All and only the roots of the composition
// can be obtained by Resolve method
var dependency = composition.Resolve<IDependency>();
```

Expand Down Expand Up @@ -96,9 +98,9 @@ classDiagram
<<abstract>>
}
Service *-- Dependency : IDependency
Composition ..> OtherService : IService SomeOtherService
Composition ..> Service : IService MyRoot
Composition ..> Dependency : IDependency _
Composition ..> OtherService : IService SomeOtherService
```

</details>
Expand Down Expand Up @@ -139,7 +141,7 @@ partial class Composition
}
}

private IDependency Root0003
private IDependency Root0002
{
[MethodImpl((MethodImplOptions)0x100)]
get
Expand Down Expand Up @@ -240,9 +242,9 @@ partial class Composition
" <<abstract>>\n" +
" }\n" +
" Service *-- Dependency : IDependency\n" +
" Composition ..> OtherService : IService SomeOtherService\n" +
" Composition ..> Service : IService MyRoot\n" +
" Composition ..> Dependency : IDependency _";
" Composition ..> Dependency : IDependency _\n" +
" Composition ..> OtherService : IService SomeOtherService";
}

private readonly static int _bucketSize;
Expand Down Expand Up @@ -307,15 +309,15 @@ partial class Composition
{
public override IDependency Resolve(Composition composition)
{
return composition.Root0003;
return composition.Root0002;
}

public override IDependency ResolveByTag(Composition composition, object tag)
{
switch (tag)
{
case null:
return composition.Root0003;
return composition.Root0002;
default:
return base.ResolveByTag(composition, tag);
}
Expand Down
Loading

0 comments on commit d43d711

Please sign in to comment.