-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathComposition.cs
43 lines (38 loc) · 1.46 KB
/
Composition.cs
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// ReSharper disable UnusedMember.Local
// ReSharper disable ArrangeTypeMemberModifiers
namespace BlazorServerApp;
using Clock.Models;
using Clock.ViewModels;
using Models;
using Pure.DI;
using Pure.DI.MS;
using WeatherForecast;
using static Pure.DI.Lifetime;
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.
void Setup() => DI.Setup()
// Use the DI setup from the base class
.DependsOn(Base)
// View Models
.Bind().To<ClockViewModel>()
// Provides the composition root for a Clock view model
.Root<IClockViewModel>(nameof(ClockViewModel))
.Bind().To<ErrorViewModel>()
// Provides the composition root for the Error view model
.Root<IErrorViewModel>()
// Services
.Bind().To<Log<TT>>()
.Bind().As(Singleton).To<Timer>()
.Bind().As(PerBlock).To<SystemClock>()
.Bind().As(Singleton).To<WeatherForecastService>()
// Provides the composition root for Weather Forecast service
.Root<IWeatherForecastService>()
.Bind().As(Singleton).To<CounterService>()
// Provides the composition root for Counter service
.Root<ICounterService>()
// Infrastructure
.Bind().To<Dispatcher>();
}