@@ -40,11 +40,6 @@ public static partial class Application // Initialization (Init/Shutdown)
4040 [ RequiresDynamicCode ( "AOT" ) ]
4141 public static void Init ( IConsoleDriver ? driver = null , string ? driverName = null )
4242 {
43- if ( driverName ? . StartsWith ( "v2" ) ?? false )
44- {
45- ApplicationImpl . ChangeInstance ( new ApplicationV2 ( ) ) ;
46- }
47-
4843 ApplicationImpl . Instance . Init ( driver , driverName ) ;
4944 }
5045
@@ -83,12 +78,6 @@ internal static void InternalInit (
8378 ResetState ( ignoreDisposed : true ) ;
8479 }
8580
86- Debug . Assert ( Navigation is null ) ;
87- Navigation = new ( ) ;
88-
89- Debug . Assert ( Popover is null ) ;
90- Popover = new ( ) ;
91-
9281 // For UnitTests
9382 if ( driver is { } )
9483 {
@@ -105,8 +94,6 @@ internal static void InternalInit (
10594 }
10695 }
10796
108- AddKeyBindings ( ) ;
109-
11097 // Ignore Configuration for ForceDriver if driverName is specified
11198 if ( ! string . IsNullOrEmpty ( driverName ) )
11299 {
@@ -130,13 +117,21 @@ internal static void InternalInit (
130117 }
131118 else
132119 {
133- List < Type ? > drivers = GetDriverTypes ( ) ;
120+ ( List < Type ? > drivers , List < string ? > driverTypeNames ) = GetDriverTypes ( ) ;
134121 Type ? driverType = drivers . FirstOrDefault ( t => t ! . Name . Equals ( ForceDriver , StringComparison . InvariantCultureIgnoreCase ) ) ;
135122
136123 if ( driverType is { } )
137124 {
138125 Driver = ( IConsoleDriver ) Activator . CreateInstance ( driverType ) ! ;
139126 }
127+ else if ( ForceDriver ? . StartsWith ( "v2" ) ?? false )
128+ {
129+ ApplicationImpl . ChangeInstance ( new ApplicationV2 ( ) ) ;
130+ ApplicationImpl . Instance . Init ( driver , ForceDriver ) ;
131+ Debug . Assert ( Driver is { } ) ;
132+
133+ return ;
134+ }
140135 else
141136 {
142137 throw new ArgumentException (
@@ -146,6 +141,14 @@ internal static void InternalInit (
146141 }
147142 }
148143
144+ Debug . Assert ( Navigation is null ) ;
145+ Navigation = new ( ) ;
146+
147+ Debug . Assert ( Popover is null ) ;
148+ Popover = new ( ) ;
149+
150+ AddKeyBindings ( ) ;
151+
149152 try
150153 {
151154 MainLoop = Driver ! . Init ( ) ;
@@ -201,10 +204,10 @@ internal static void UnsubscribeDriverEvents ()
201204 private static void Driver_KeyUp ( object ? sender , Key e ) { RaiseKeyUpEvent ( e ) ; }
202205 private static void Driver_MouseEvent ( object ? sender , MouseEventArgs e ) { RaiseMouseEvent ( e ) ; }
203206
204- /// <summary>Gets of list of <see cref="IConsoleDriver"/> types that are available.</summary>
207+ /// <summary>Gets of list of <see cref="IConsoleDriver"/> types and type names that are available.</summary>
205208 /// <returns></returns>
206209 [ RequiresUnreferencedCode ( "AOT" ) ]
207- public static List < Type ? > GetDriverTypes ( )
210+ public static ( List < Type ? > , List < string ? > ) GetDriverTypes ( )
208211 {
209212 // use reflection to get the list of drivers
210213 List < Type ? > driverTypes = new ( ) ;
@@ -220,7 +223,13 @@ internal static void UnsubscribeDriverEvents ()
220223 }
221224 }
222225
223- return driverTypes ;
226+ List < string ? > driverTypeNames = driverTypes
227+ . Where ( d => ! typeof ( IConsoleDriverFacade ) . IsAssignableFrom ( d ) )
228+ . Select ( d => d ! . Name )
229+ . Union ( [ "v2" , "v2win" , "v2net" ] )
230+ . ToList ( ) ! ;
231+
232+ return ( driverTypes , driverTypeNames ) ;
224233 }
225234
226235 /// <summary>Shutdown an application initialized with <see cref="Init"/>.</summary>
0 commit comments