File tree Expand file tree Collapse file tree 9 files changed +35
-38
lines changed
ConsoleTools.Commando.Demo.Autofac.Builder/Commands
ConsoleTools.Commando.Demo.Autofac.DependencyInjection/Commands
ConsoleTools.Commando.Demo.Microsoft.Builder/Commands
ConsoleTools.Commando.Demo.Microsoft.DependencyInjection/Commands
ConsoleTools.Commando.Demo.Ninject.Builder/Commands
ConsoleTools.Commando.Setup.Microsoft
ConsoleTools.Commando.Setup.Ninject Expand file tree Collapse file tree 9 files changed +35
-38
lines changed Original file line number Diff line number Diff line change 1616
1717namespace DustInTheWind . ConsoleTools . Commando . Demo . Autofac . Builder . Commands ;
1818
19- [ DefaultCommand ( Order = 100 , Description = "Default command to be executed when no command name is specified." ) ]
19+ [ Command ( Order = 100 , Description = "Default command to be executed when no command name is specified." ) ]
2020public class DefaultCommand : CommandBase
2121{
2222 [ NamedParameter ( "text" ) ]
Original file line number Diff line number Diff line change 1616
1717namespace DustInTheWind . ConsoleTools . Commando . Demo . Autofac . DependencyInjection . Commands ;
1818
19- [ DefaultCommand ( Order = 100 , Description = "Default command to be executed when no command name is specified." ) ]
19+ [ Command ( Order = 100 , Description = "Default command to be executed when no command name is specified." ) ]
2020public class DefaultCommand : CommandBase
2121{
2222 [ NamedParameter ( "text" ) ]
Original file line number Diff line number Diff line change 1616
1717namespace DustInTheWind . ConsoleTools . Commando . Demo . Microsoft . Builder . Commands ;
1818
19- [ DefaultCommand ( Order = 100 , Description = "Default command to be executed when no command name is specified." ) ]
19+ [ Command ( Order = 100 , Description = "Default command to be executed when no command name is specified." ) ]
2020public class DefaultCommand : CommandBase
2121{
2222 [ NamedParameter ( "text" ) ]
Original file line number Diff line number Diff line change 1616
1717namespace DustInTheWind . ConsoleTools . Commando . Demo . Microsoft . DependencyInjection . Commands ;
1818
19- [ DefaultCommand ( Order = 100 , Description = "Default command to be executed when no command name is specified." ) ]
19+ [ Command ( Order = 100 , Description = "Default command to be executed when no command name is specified." ) ]
2020public class DefaultCommand : CommandBase
2121{
2222 [ NamedParameter ( "text" ) ]
Original file line number Diff line number Diff line change 1616
1717namespace DustInTheWind . ConsoleTools . Commando . Demo . Ninject . Builder . Commands ;
1818
19- [ DefaultCommand ( Order = 100 , Description = "Default command to be executed when no command name is specified." ) ]
19+ [ Command ( Order = 100 , Description = "Default command to be executed when no command name is specified." ) ]
2020public class DefaultCommand : CommandBase
2121{
2222 [ NamedParameter ( "text" ) ]
Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ public class ApplicationBuilder
2626 private readonly IServiceCollection serviceCollection ;
2727 private readonly CommandMetadataCollection commandMetadataCollection ;
2828 private bool isCommandParserConfigured ;
29+ private EventHandler < UnhandledApplicationExceptionEventArgs > unhandledExceptionHandler ;
2930
3031 public ApplicationBuilder ( )
3132 {
@@ -115,10 +116,22 @@ public ApplicationBuilder ConfigureServices(Action<IServiceCollection> action)
115116 return this ;
116117 }
117118
119+ public ApplicationBuilder HandleExceptions ( EventHandler < UnhandledApplicationExceptionEventArgs > eventHandler )
120+ {
121+ unhandledExceptionHandler = eventHandler ;
122+
123+ return this ;
124+ }
125+
118126 public Application Build ( )
119127 {
120128 IServiceProvider serviceProvider = FinalizeContainerSetup ( ) ;
121- return serviceProvider . GetService < Application > ( ) ;
129+ Application application = serviceProvider . GetService < Application > ( ) ;
130+
131+ if ( unhandledExceptionHandler != null )
132+ application . UnhandledApplicationException += unhandledExceptionHandler ;
133+
134+ return application ;
122135 }
123136
124137 private IServiceProvider FinalizeContainerSetup ( )
Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ public class ApplicationBuilder
2626 private readonly IKernel kernel ;
2727 private readonly CommandMetadataCollection commandMetadataCollection ;
2828 private bool isCommandParserConfigured ;
29+ private EventHandler < UnhandledApplicationExceptionEventArgs > unhandledExceptionHandler ;
2930
3031 private ApplicationBuilder ( )
3132 {
@@ -110,10 +111,22 @@ public ApplicationBuilder ConfigureServices(Action<IKernel> action)
110111 return this ;
111112 }
112113
114+ public ApplicationBuilder HandleExceptions ( EventHandler < UnhandledApplicationExceptionEventArgs > eventHandler )
115+ {
116+ unhandledExceptionHandler = eventHandler ;
117+
118+ return this ;
119+ }
120+
113121 public Application Build ( )
114122 {
115123 IKernel container = FinalizeContainerSetup ( ) ;
116- return container . Get < Application > ( ) ;
124+ Application application = container . Get < Application > ( ) ;
125+
126+ if ( unhandledExceptionHandler != null )
127+ application . UnhandledApplicationException += unhandledExceptionHandler ;
128+
129+ return application ;
117130 }
118131
119132 private IKernel FinalizeContainerSetup ( )
Original file line number Diff line number Diff line change @@ -36,10 +36,9 @@ public class CommandAttribute : Attribute
3636 public bool Enabled { get ; set ; } = true ;
3737
3838 /// <summary>
39- /// Creates a new instance of the <see cref="CommandAttribute" /> with
40- /// no name.
39+ /// Creates a new instance of the <see cref="CommandAttribute" /> class.
4140 /// </summary>
42- protected CommandAttribute ( )
41+ public CommandAttribute ( )
4342 {
4443 }
4544}
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments