public Task <IBinding> TryCreateAsync(BindingProviderContext context)
        {
            ParameterInfo parameter = context.Parameter;

            if (parameter.ParameterType != typeof(ICommandContext))
            {
                return(Task.FromResult <IBinding>(null));
            }

            /// For Functions demarked with ServerlessCqrsCommandContextAttribute, check the declaring type
            /// for presence of ServerlessCqrsAttribute and capture any global settings from it.
            var parameterAttribute = parameter.GetCustomAttribute <ServerlessCqrsCommandContextAttribute>();
            var typeAttribute      = parameter.Member.DeclaringType.GetCustomAttribute <ServerlessCqrsAttribute>(false);

            var descriptor = CommandContextDescriptor.Create(nameResolver, parameterAttribute, typeAttribute ?? new ServerlessCqrsAttribute());

            return(Task.FromResult <IBinding>(new CommandContextBinding(parameter.Name, descriptor, options)));
        }
 internal CommandContextValueProvider(CommandContextDescriptor descriptor, ServerlessCqrsOptions options)
 {
     this.descriptor = descriptor;
     this.options    = options;
 }
Exemple #3
0
 internal CommandContextBinding(string parameterName, CommandContextDescriptor descriptor, ServerlessCqrsOptions options)
 {
     this.parameterName = parameterName;
     this.descriptor    = descriptor;
     this.options       = options;
 }