-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathComposition.cs
More file actions
26 lines (22 loc) · 881 Bytes
/
Composition.cs
File metadata and controls
26 lines (22 loc) · 881 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
using Pure.DI;
using Pure.DI.MS;
using static Pure.DI.Lifetime;
// ReSharper disable UnusedMember.Local
namespace MinimalWebAPI;
partial class Composition : ServiceProviderFactory<Composition>
{
// IMPORTANT:
// Only composition roots (regular or anonymous) can be resolved through the `IServiceProvider` interface.
// These roots must be registered using `Root<>(...)` or `RootBind<>()` calls.
[Conditional("DI")]
private void Setup() => DI.Setup()
// Owned is used here to dispose of all disposable instances associated with the root.
.Root<Owned<Program>>(nameof(Root))
.Root<IClockViewModel>()
.Bind().To<ClockViewModel>()
.Bind().To<ClockModel>()
.Bind().As(Singleton).To<Ticks>()
// Infrastructure
.Bind().To<MicrosoftLoggerAdapter<TT>>()
.Bind().To<CurrentThreadDispatcher>();
}