@@ -17,6 +17,7 @@ namespace CSharpInteractive;
1717using Microsoft . CodeAnalysis . CSharp ;
1818using Microsoft . CodeAnalysis . Scripting ;
1919using Pure . DI ;
20+ using static DateTime ;
2021using static Pure . DI . Lifetime ;
2122using static Pure . DI . Tag ;
2223using CommandLineParser = Core . CommandLineParser ;
@@ -29,8 +30,8 @@ internal partial class Composition
2930 private static void Setup ( )
3031 {
3132 DI . Setup ( )
32- . Hint ( Hint . Resolve , " Off" )
33- . Root < Root > ( " Root" )
33+ . Hint ( Hint . Resolve , Name . Off )
34+ . Root < Root > ( nameof ( Root ) )
3435
3536#if TOOL
3637 . DefaultLifetime ( Transient )
@@ -40,12 +41,12 @@ private static void Setup()
4041 ctx . Inject < ISettings > ( out var settings ) ;
4142 if ( settings . InteractionMode == InteractionMode . Interactive )
4243 {
43- ctx . Inject < IScriptRunner > ( InteractionMode . Interactive , out var scriptRunner ) ;
44+ ctx . Inject < IScriptRunner > ( InteractiveTag , out var scriptRunner ) ;
4445 return scriptRunner ;
4546 }
4647 else
4748 {
48- ctx . Inject < IScriptRunner > ( InteractionMode . NonInteractive , out var scriptRunner ) ;
49+ ctx . Inject < IScriptRunner > ( NonInteractiveTag , out var scriptRunner ) ;
4950 return scriptRunner ;
5051 }
5152 } )
@@ -58,8 +59,8 @@ private static void Setup()
5859 . DefaultLifetime ( Singleton )
5960 . Bind ( Unique ) . To < ExitManager > ( )
6061 . 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 > ( )
6364 . Bind ( ) . To < CommandSource > ( )
6465 . Bind ( ) . To < Setting < TTE > > ( )
6566 . Bind ( Unique ) . Bind < IReferenceRegistry > ( ) . To < ReferencesScriptOptionsFactory > ( )
@@ -68,19 +69,19 @@ private static void Setup()
6869 . Bind ( ) . As ( Transient ) . To ( _ => RunningMode . Application )
6970#endif
7071 . DefaultLifetime ( Transient )
71- . Bind ( ) . To ( _ => DateTime . Now )
72+ . Bind ( ) . To ( _ => Now )
7273 . Bind ( ) . To ( _ => typeof ( Composition ) . Assembly )
7374 . 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 )
7576 . 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 )
7778 . 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 )
7980 . Bind ( ) . To < ScriptCommandFactory > ( )
8081 . Bind ( ) . To < ReliableBuildContext > ( )
8182 . Bind ( ) . To < ProcessMonitor > ( )
8283 . Bind ( ) . To < ProcessManager > ( )
83- . Bind ( Base ) . To < BuildContext > ( )
84+ . Bind ( BaseTag ) . To < BuildContext > ( )
8485 . Bind ( ) . To ( _ => MemoryPool < TT > . Shared )
8586 . Bind ( ) . To < SourceResolver > ( )
8687 . Bind ( ) . To < MetadataResolver > ( )
@@ -119,12 +120,12 @@ private static void Setup()
119120 . Bind ( ) . To < FileExplorer > ( )
120121 . Bind ( ) . To < Utf8Encoding > ( )
121122 . Bind ( ) . To < BuildOutputProcessor > ( )
122- . Bind ( Base ) . To < DefaultBuildMessagesProcessor > ( )
123- . Bind ( Custom ) . To < CustomMessagesProcessor > ( )
123+ . Bind ( BaseTag ) . To < DefaultBuildMessagesProcessor > ( )
124+ . Bind ( CustomTag ) . To < CustomMessagesProcessor > ( )
124125 . Bind ( ) . To < TeamCityContext > ( )
125126 . Bind ( ) . To < SummaryPresenter > ( )
126127 . Bind ( ) . To < ExitCodeParser > ( )
127- . Bind ( Base ) . To < ProcessRunner > ( )
128+ . Bind ( BaseTag ) . To < ProcessRunner > ( )
128129 . Bind ( ) . To < ProcessResultHandler > ( )
129130 . Bind ( ) . To < TextReplacer > ( )
130131 . Bind ( ) . To < RuntimeExplorer > ( )
@@ -133,14 +134,14 @@ private static void Setup()
133134 . Bind ( ) . To < Root > ( )
134135 . Bind ( ) . To ( _ => new CancellationTokenSource ( ) )
135136 . 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 > ( )
139140 . Bind ( ) . To < Console > ( )
140141 . Bind ( ) . To ( ( ICISpecific < IStdOut > stdOut ) => stdOut . Instance )
141142 . 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 > > ( )
144145 . Bind ( ) . To ( ( ICISpecific < ILog < TT > > log ) => log . Instance )
145146 . Bind ( ) . To < CISettings > ( )
146147 . Bind ( ) . To < ExitTracker > ( )
@@ -149,18 +150,8 @@ private static void Setup()
149150 . Bind ( ) . To < Settings > ( )
150151 . Bind ( ) . To < Info > ( )
151152 . 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 > ( )
164155 . Bind ( ) . To < Statistics > ( )
165156 . Bind ( ) . To < CommandsRunner > ( )
166157 . Bind ( ) . To < CodeSourceCommandFactory > ( )
@@ -202,8 +193,8 @@ private static void Setup()
202193 . Bind ( Unique ) . To < SettingCommandRunner < VerbosityLevel > > ( )
203194 . Bind ( Unique ) . To < AddNuGetReferenceCommandFactory > ( )
204195 . 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 > ( )
207198 . Bind ( ) . To ( ( ICISpecific < IProperties > properties ) => properties . Instance )
208199
209200 // Public services
@@ -215,8 +206,9 @@ private static void Setup()
215206 . Bind ( ) . To < ServiceMessageFormatter > ( )
216207 . Bind ( ) . To < FlowIdGenerator > ( )
217208 . 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 > ( )
220212 . Bind ( ) . To < ServiceMessageParser > ( ) ;
221213 }
222214}
0 commit comments