-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathModuleC.cs
More file actions
50 lines (45 loc) · 1.7 KB
/
ModuleC.cs
File metadata and controls
50 lines (45 loc) · 1.7 KB
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
44
45
46
47
48
49
50
using Lemon.ModuleNavigation.Abstractions;
using Lemon.ModuleNavigation.Sample.ModuleCs.SubModules;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using ILogger = Microsoft.Extensions.Logging.ILogger;
namespace Lemon.ModuleNavigation.Sample.ModuleCs;
public class ModuleC : Module<ViewC, ViewModelC>, IModuleScope
{
private readonly IServiceProvider _subServiceProvider;
private readonly ILogger _logger;
public ModuleC(IServiceProvider serviceProvider, ILogger<ModuleC> logger) : base(serviceProvider)
{
_logger = logger;
ScopeServiceCollection = new ServiceCollection();
ScopeServiceCollection.AddAppServiceProvider(serviceProvider);
ScopeServiceCollection.AddModule<SubModule01>();
ScopeServiceCollection.AddModule<SubModule02>();
ScopeServiceCollection.AddAvaNavigationSupport();
_subServiceProvider = ScopeServiceCollection.BuildServiceProvider();
ScopeServiceProvider = _subServiceProvider;
}
public IServiceCollection ScopeServiceCollection
{
get;
}
public IServiceProvider ScopeServiceProvider
{
get;
}
public override bool LoadOnDemand => true;
public override bool ForceNew => true;
public override string Alias => $"{base.Alias}:{nameof(ForceNew)}";
public override void Initialize()
{
base.Initialize();
Console.WriteLine($"Initialize:{nameof(ModuleC)}");
var subModules = _subServiceProvider.GetRequiredService<IEnumerable<IModule>>();
foreach (var subModule in subModules)
{
_logger.LogInformation(subModule.Key);
}
}
}