Skip to content

Instantly share code, notes, and snippets.

@GeradeDev
Created July 17, 2020 10:57
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save GeradeDev/e55d6ee39e93a9f3bfff2faf3cc9d763 to your computer and use it in GitHub Desktop.
public class RabbitMqTriggerBindingProvider : ITriggerBindingProvider
{
private readonly ILogger _logger;
public RabbitMqTriggerBindingProvider(ILogger logger)
{
_logger = logger;
}
public Task<ITriggerBinding> TryCreateAsync(TriggerBindingProviderContext context)
{
var parameter = context.Parameter;
var attribute = parameter.GetCustomAttribute<RabbitMqTriggerAttribute>(false);
if (attribute == null) return Task.FromResult<ITriggerBinding>(null);
if (parameter.ParameterType != typeof(BasicDeliverEventArgs)) throw new InvalidOperationException("Invalid parameter type");
var triggerBinding = new RabbitMqTriggerBinding(parameter, _logger);
return Task.FromResult<ITriggerBinding>(triggerBinding);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment