예제 #1
0
 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}");
     }
 }
예제 #2
0
 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}");
     }
 }
예제 #3
0
        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();
            }
        }
예제 #4
0
 public ValueTask <int> OnCommandExecutionAsync(CoconaCommandExecutingContext ctx, CommandExecutionDelegate next)
 {
     throw new NotImplementedException();
 }