public CachedQueryInvalidatorInterceptor(CommandExecutionDelegate next, IHostApplicationLifetime applicationLifetime, ICache cache, Type[]?queryTypes, ILogger <CachedQueryInvalidatorInterceptor>?logger) { _next = next ?? throw new ArgumentNullException(nameof(next)); _applicationLifetime = applicationLifetime ?? throw new ArgumentNullException(nameof(applicationLifetime)); Cache = cache ?? throw new ArgumentNullException(nameof(cache)); _queryTypes = queryTypes ?? Type.EmptyTypes; _logger = logger ?? (ILogger)NullLogger.Instance; }
public override ValueTask <int> DispatchAsync(CommandDispatchContext ctx) { var filters = FilterHelper.GetFilters <ICommandFilter>(ctx.Command.Method, _serviceProvider); CommandExecutionDelegate next = (ctx2) => Next(ctx); foreach (var filter in filters) { var next_ = next; next = (ctx2) => filter.OnCommandExecutionAsync(ctx2, next_); } return(next(new CoconaCommandExecutingContext(ctx.Command, ctx.ParsedCommandLine, ctx.CommandTarget))); }
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 ValueTask <int> OnCommandExecutionAsync(CoconaCommandExecutingContext ctx, CommandExecutionDelegate next) { throw new NotImplementedException(); }
public CommandPerformanceLoggerInterceptor(CommandExecutionDelegate next, IGuidProvider guidProvider, ILogger <CommandPerformanceLoggerInterceptor>?logger) { _next = next ?? throw new ArgumentNullException(nameof(next)); _guidProvider = guidProvider ?? throw new ArgumentNullException(nameof(guidProvider)); _logger = logger ?? (ILogger)NullLogger.Instance; }
public CommandDataAnnotationsValidatorInterceptor(CommandExecutionDelegate next) { _next = next ?? throw new ArgumentNullException(nameof(next)); }
public GetCachedUserInfoQueryInvalidatorInterceptor(CommandExecutionDelegate next, IHostApplicationLifetime applicationLifetime, ICache cache, Type[]?queryTypes, ILogger <CachedQueryInvalidatorInterceptor>?logger) : base(next, applicationLifetime, cache, queryTypes, logger) { }
public ValueTask <int> OnCommandExecutionAsync(CoconaCommandExecutingContext ctx, CommandExecutionDelegate next) { return(next(ctx)); }
public abstract ValueTask <int> OnCommandExecutionAsync(CoconaCommandExecutingContext ctx, CommandExecutionDelegate next);
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(); } }