public async ValueTask <int> OnCommandExecutionAsync(CoconaCommandExecutingContext ctx, CommandExecutionDelegate next) { _logger.LogInformation($"[SampleCommandFilterWithDI] Before Command: {ctx.Command.Name}"); try { return(await next(ctx)); } catch (Exception ex) { _logger.LogInformation($"[SampleCommandFilterWithDI] Exception: {ex.GetType().FullName}: {ex.Message}"); throw; } finally { _logger.LogInformation($"[SampleCommandFilterWithDI] End Command: {ctx.Command.Name}"); } }
public override async ValueTask <int> OnCommandExecutionAsync(CoconaCommandExecutingContext ctx, CommandExecutionDelegate next) { Console.WriteLine($"[SampleCommandFilter({_label})] Before Command: {ctx.Command.Name}"); try { return(await next(ctx)); } catch (Exception ex) { Console.WriteLine($"[SampleCommandFilter({_label})] Exception: {ex.GetType().FullName}: {ex.Message}"); throw; } finally { Console.WriteLine($"[SampleCommandFilter({_label})] End Command: {ctx.Command.Name}"); } }
public override async ValueTask <int> OnCommandExecutionAsync(CoconaCommandExecutingContext ctx, CommandExecutionDelegate next) { var tcs = new TaskCompletionSource <bool>(); _mutexAcquireThread.Start(tcs); try { var acquired = await tcs.Task; if (!acquired) { Console.Error.WriteLine("Error: The application is already running."); return(1); } return(await next(ctx)); } finally { _waitForExit.Set(); _mutexAcquireThread.Join(); } }
public ValueTask <int> OnCommandExecutionAsync(CoconaCommandExecutingContext ctx, CommandExecutionDelegate next) { throw new NotImplementedException(); }