forked from scriptcs/scriptcs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathServiceOverrides.cs
More file actions
111 lines (91 loc) · 3.14 KB
/
ServiceOverrides.cs
File metadata and controls
111 lines (91 loc) · 3.14 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
using System;
using System.Collections.Generic;
using ScriptCs.Contracts;
namespace ScriptCs
{
public abstract class ServiceOverrides<TConfig> : IServiceOverrides<TConfig>
where TConfig : class, IServiceOverrides<TConfig>
{
protected readonly IList<Type> LineProcessors = new List<Type>();
protected readonly IDictionary<Type, object> Overrides = new Dictionary<Type, object>();
private readonly TConfig _this;
protected ServiceOverrides()
{
_this = this as TConfig;
}
protected ServiceOverrides(IDictionary<Type, object> overrides)
{
Overrides = overrides;
}
public TConfig ScriptExecutor<T>() where T : IScriptExecutor
{
Overrides[typeof(IScriptExecutor)] = typeof(T);
return _this;
}
public TConfig ScriptEngine<T>() where T : IScriptEngine
{
Overrides[typeof(IScriptEngine)] = typeof(T);
return _this;
}
public TConfig ScriptHostFactory<T>() where T : IScriptHostFactory
{
Overrides[typeof(IScriptHostFactory)] = typeof(T);
return _this;
}
public TConfig ScriptPackManager<T>() where T : IScriptPackManager
{
Overrides[typeof(IScriptPackManager)] = typeof(T);
return _this;
}
public TConfig ScriptPackResolver<T>() where T : IScriptPackResolver
{
Overrides[typeof(IScriptPackResolver)] = typeof(T);
return _this;
}
public TConfig InstallationProvider<T>() where T : IInstallationProvider
{
Overrides[typeof(IInstallationProvider)] = typeof(T);
return _this;
}
public TConfig FileSystem<T>() where T : IFileSystem
{
Overrides[typeof(IFileSystem)] = typeof(T);
return _this;
}
public TConfig AssemblyUtility<T>() where T : IAssemblyUtility
{
Overrides[typeof(IAssemblyUtility)] = typeof(T);
return _this;
}
public TConfig PackageContainer<T>() where T : IPackageContainer
{
Overrides[typeof(IPackageContainer)] = typeof(T);
return _this;
}
public TConfig PackageInstaller<T>() where T : IPackageInstaller
{
Overrides[typeof(IPackageInstaller)] = typeof(T);
return _this;
}
public TConfig FilePreProcessor<T>() where T : IFilePreProcessor
{
Overrides[typeof(IFilePreProcessor)] = typeof(T);
return _this;
}
public TConfig PackageAssemblyResolver<T>() where T : IPackageAssemblyResolver
{
Overrides[typeof(IPackageAssemblyResolver)] = typeof(T);
return _this;
}
public TConfig AssemblyResolver<T>() where T : IAssemblyResolver
{
Overrides[typeof(IAssemblyResolver)] = typeof(T);
return _this;
}
public TConfig LineProcessor<T>() where T : ILineProcessor
{
LineProcessors.Add(typeof(T));
return _this;
}
}
}