-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDefaultLoader.cs
51 lines (46 loc) · 2.04 KB
/
DefaultLoader.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
44
45
46
47
48
49
50
51
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace FreeSWITCH.Managed
{
public class DefaultLoader
{
private DefaultModuleDirectorySupervisor directorySupervisor;
private ExecuteBackgroundCommandOnCollection executeBackgroundCommand;
private ExecuteCommandOnCollection executeCommand;
private ILoggerContainer logger;
private ReloadCommandOnCollection reloadCommand;
private AssemblyResolver resolver;
private RunCommandOnCollection runCommand;
// Thread-safe singleton implementation from: http://www.yoda.arachsys.com/csharp/singleton.html
static DefaultLoader() { DefaultLoader.Loader = DefaultServiceLocator.Container.Create<DefaultLoader>(); }
public static DefaultLoader Loader { get; private set; }
public DefaultLoader(RunCommandOnCollection runCommand,
ExecuteCommandOnCollection executeCommand,
ExecuteBackgroundCommandOnCollection executeBackgroundCommand,
ReloadCommandOnCollection reloadCommand,
AssemblyResolver resolver,
DefaultModuleDirectorySupervisor directorySupervisor,
ILoggerContainer logger)
{
this.logger = logger;
this.directorySupervisor = directorySupervisor;
this.resolver = resolver;
this.reloadCommand = reloadCommand;
this.executeBackgroundCommand = executeBackgroundCommand;
this.executeCommand = executeCommand;
this.runCommand = runCommand;
}
public bool Load()
{
CoreDelegates.Run = this.runCommand.Run;
CoreDelegates.Execute = this.executeCommand.Execute;
CoreDelegates.ExecuteBackground = this.executeBackgroundCommand.ExecuteBackground;
CoreDelegates.Reload = this.reloadCommand.Reload;
this.logger.Info("Load completed.");
this.resolver.AttachDefaultAssemblyResolver();
return this.directorySupervisor.Initialize();
}
}
}