@@ -17,6 +17,7 @@ namespace CSharpInteractive;
17
17
using Microsoft . CodeAnalysis . CSharp ;
18
18
using Microsoft . CodeAnalysis . Scripting ;
19
19
using Pure . DI ;
20
+ using static DateTime ;
20
21
using static Pure . DI . Lifetime ;
21
22
using static Pure . DI . Tag ;
22
23
using CommandLineParser = Core . CommandLineParser ;
@@ -29,8 +30,8 @@ internal partial class Composition
29
30
private static void Setup ( )
30
31
{
31
32
DI . Setup ( )
32
- . Hint ( Hint . Resolve , " Off" )
33
- . Root < Root > ( " Root" )
33
+ . Hint ( Hint . Resolve , Name . Off )
34
+ . Root < Root > ( nameof ( Root ) )
34
35
35
36
#if TOOL
36
37
. DefaultLifetime ( Transient )
@@ -40,12 +41,12 @@ private static void Setup()
40
41
ctx . Inject < ISettings > ( out var settings ) ;
41
42
if ( settings . InteractionMode == InteractionMode . Interactive )
42
43
{
43
- ctx . Inject < IScriptRunner > ( InteractionMode . Interactive , out var scriptRunner ) ;
44
+ ctx . Inject < IScriptRunner > ( InteractiveTag , out var scriptRunner ) ;
44
45
return scriptRunner ;
45
46
}
46
47
else
47
48
{
48
- ctx . Inject < IScriptRunner > ( InteractionMode . NonInteractive , out var scriptRunner ) ;
49
+ ctx . Inject < IScriptRunner > ( NonInteractiveTag , out var scriptRunner ) ;
49
50
return scriptRunner ;
50
51
}
51
52
} )
@@ -58,8 +59,8 @@ private static void Setup()
58
59
. DefaultLifetime ( Singleton )
59
60
. Bind ( Unique ) . To < ExitManager > ( )
60
61
. Bind ( Unique ) . To < Debugger > ( )
61
- . Bind ( InteractionMode . Interactive ) . To < InteractiveRunner > ( )
62
- . Bind ( InteractionMode . NonInteractive ) . To < ScriptRunner > ( )
62
+ . Bind ( InteractiveTag ) . To < InteractiveRunner > ( )
63
+ . Bind ( NonInteractiveTag ) . To < ScriptRunner > ( )
63
64
. Bind ( ) . To < CommandSource > ( )
64
65
. Bind ( ) . To < Setting < TTE > > ( )
65
66
. Bind ( Unique ) . Bind < IReferenceRegistry > ( ) . To < ReferencesScriptOptionsFactory > ( )
@@ -68,19 +69,19 @@ private static void Setup()
68
69
. Bind ( ) . As ( Transient ) . To ( _ => RunningMode . Application )
69
70
#endif
70
71
. DefaultLifetime ( Transient )
71
- . Bind ( ) . To ( _ => DateTime . Now )
72
+ . Bind ( ) . To ( _ => Now )
72
73
. Bind ( ) . To ( _ => typeof ( Composition ) . Assembly )
73
74
. Bind ( ) . To ( _ => new CSharpParseOptions ( ) . LanguageVersion )
74
- . Bind ( RuntimePath ) . To ( _ => Path . GetDirectoryName ( typeof ( object ) . Assembly . Location ) ?? string . Empty )
75
+ . Bind ( RuntimePathTag ) . To ( _ => Path . GetDirectoryName ( typeof ( object ) . Assembly . Location ) ?? string . Empty )
75
76
. Bind ( ) . To ( ( CancellationTokenSource cancellationTokenSource ) => cancellationTokenSource . Token )
76
- . Bind ( TargetFrameworkMoniker ) . To ( ( Assembly assembly ) => assembly . GetCustomAttribute < System . Runtime . Versioning . TargetFrameworkAttribute > ( ) ? . FrameworkName ?? string . Empty )
77
+ . Bind ( TargetFrameworkMonikerTag ) . To ( ( Assembly assembly ) => assembly . GetCustomAttribute < System . Runtime . Versioning . TargetFrameworkAttribute > ( ) ? . FrameworkName ?? string . Empty )
77
78
. Bind ( ) . To ( _ => Process . GetCurrentProcess ( ) )
78
- . Bind ( ModuleFile ) . To ( ( Process process ) => process . MainModule ? . FileName ?? string . Empty )
79
+ . Bind ( ModuleFileTag ) . To ( ( Process process ) => process . MainModule ? . FileName ?? string . Empty )
79
80
. Bind ( ) . To < ScriptCommandFactory > ( )
80
81
. Bind ( ) . To < ReliableBuildContext > ( )
81
82
. Bind ( ) . To < ProcessMonitor > ( )
82
83
. Bind ( ) . To < ProcessManager > ( )
83
- . Bind ( Base ) . To < BuildContext > ( )
84
+ . Bind ( BaseTag ) . To < BuildContext > ( )
84
85
. Bind ( ) . To ( _ => MemoryPool < TT > . Shared )
85
86
. Bind ( ) . To < SourceResolver > ( )
86
87
. Bind ( ) . To < MetadataResolver > ( )
@@ -119,12 +120,12 @@ private static void Setup()
119
120
. Bind ( ) . To < FileExplorer > ( )
120
121
. Bind ( ) . To < Utf8Encoding > ( )
121
122
. Bind ( ) . To < BuildOutputProcessor > ( )
122
- . Bind ( Base ) . To < DefaultBuildMessagesProcessor > ( )
123
- . Bind ( Custom ) . To < CustomMessagesProcessor > ( )
123
+ . Bind ( BaseTag ) . To < DefaultBuildMessagesProcessor > ( )
124
+ . Bind ( CustomTag ) . To < CustomMessagesProcessor > ( )
124
125
. Bind ( ) . To < TeamCityContext > ( )
125
126
. Bind ( ) . To < SummaryPresenter > ( )
126
127
. Bind ( ) . To < ExitCodeParser > ( )
127
- . Bind ( Base ) . To < ProcessRunner > ( )
128
+ . Bind ( BaseTag ) . To < ProcessRunner > ( )
128
129
. Bind ( ) . To < ProcessResultHandler > ( )
129
130
. Bind ( ) . To < TextReplacer > ( )
130
131
. Bind ( ) . To < RuntimeExplorer > ( )
@@ -133,14 +134,14 @@ private static void Setup()
133
134
. Bind ( ) . To < Root > ( )
134
135
. Bind ( ) . To ( _ => new CancellationTokenSource ( ) )
135
136
. Bind ( ) . To < CISpecific < TT > > ( )
136
- . Bind ( Base ) . To < ConsoleInOut > ( )
137
- . Bind ( TeamCity ) . To < TeamCityInOut > ( )
138
- . Bind ( Ansi ) . To < AnsiInOut > ( )
137
+ . Bind ( BaseTag ) . To < ConsoleInOut > ( )
138
+ . Bind ( TeamCityTag ) . To < TeamCityInOut > ( )
139
+ . Bind ( AnsiTag ) . To < AnsiInOut > ( )
139
140
. Bind ( ) . To < Console > ( )
140
141
. Bind ( ) . To ( ( ICISpecific < IStdOut > stdOut ) => stdOut . Instance )
141
142
. Bind ( ) . To ( ( ICISpecific < IStdErr > stdErr ) => stdErr . Instance )
142
- . Bind ( Base , Ansi ) . To < Log < TT > > ( )
143
- . Bind ( TeamCity ) . To < TeamCityLog < TT > > ( )
143
+ . Bind ( BaseTag , AnsiTag ) . To < Log < TT > > ( )
144
+ . Bind ( TeamCityTag ) . To < TeamCityLog < TT > > ( )
144
145
. Bind ( ) . To ( ( ICISpecific < ILog < TT > > log ) => log . Instance )
145
146
. Bind ( ) . To < CISettings > ( )
146
147
. Bind ( ) . To < ExitTracker > ( )
@@ -149,18 +150,8 @@ private static void Setup()
149
150
. Bind ( ) . To < Settings > ( )
150
151
. Bind ( ) . To < Info > ( )
151
152
. Bind ( ) . To < ConsoleSource > ( )
152
- . Bind ( LoadFileCode ) . To ( ctx => new Func < string , ICodeSource > ( name =>
153
- {
154
- ctx . Inject < LoadFileCodeSource > ( out var loadFileCodeSource ) ;
155
- loadFileCodeSource . Name = name ;
156
- return loadFileCodeSource ;
157
- } ) )
158
- . Bind ( LineCode ) . To ( ctx => new Func < string , ICodeSource > ( line =>
159
- {
160
- ctx . Inject < LineCodeSource > ( out var lineCodeSource ) ;
161
- lineCodeSource . Line = line ;
162
- return lineCodeSource ;
163
- } ) )
153
+ . Bind ( LoadFileCodeTag ) . To < LoadFileCodeSource > ( )
154
+ . Bind ( LineCodeTag ) . To < LineCodeSource > ( )
164
155
. Bind ( ) . To < Statistics > ( )
165
156
. Bind ( ) . To < CommandsRunner > ( )
166
157
. Bind ( ) . To < CodeSourceCommandFactory > ( )
@@ -202,8 +193,8 @@ private static void Setup()
202
193
. Bind ( Unique ) . To < SettingCommandRunner < VerbosityLevel > > ( )
203
194
. Bind ( Unique ) . To < AddNuGetReferenceCommandFactory > ( )
204
195
. Bind ( Unique ) . To < AddNuGetReferenceCommandRunner > ( )
205
- . Bind ( Base , Ansi ) . To < Properties > ( )
206
- . Bind ( TeamCity ) . To < TeamCityProperties > ( )
196
+ . Bind ( BaseTag , AnsiTag ) . To < Properties > ( )
197
+ . Bind ( TeamCityTag ) . To < TeamCityProperties > ( )
207
198
. Bind ( ) . To ( ( ICISpecific < IProperties > properties ) => properties . Instance )
208
199
209
200
// Public services
@@ -215,8 +206,9 @@ private static void Setup()
215
206
. Bind ( ) . To < ServiceMessageFormatter > ( )
216
207
. Bind ( ) . To < FlowIdGenerator > ( )
217
208
. Bind ( ) . To < TimestampUpdater > ( )
218
- . Bind ( ) . To ( ( ITeamCityServiceMessages teamCityServiceMessages , IConsole console )
219
- => new SafeTeamCityWriter ( teamCityServiceMessages . CreateWriter ( str => console . WriteToOut ( ( null , str + "\n " ) ) ) ) )
209
+ . Bind ( BaseTag ) . To ( ( ITeamCityServiceMessages teamCityServiceMessages , IConsole console )
210
+ => teamCityServiceMessages . CreateWriter ( str => console . WriteToOut ( ( null , str + "\n " ) ) ) )
211
+ . Bind ( ) . To < SafeTeamCityWriter > ( )
220
212
. Bind ( ) . To < ServiceMessageParser > ( ) ;
221
213
}
222
214
}
0 commit comments