Esempio n. 1
0
        public Task <ITriggerBinding> TryCreateAsync(TriggerBindingProviderContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            ParameterInfo parameter = context.Parameter;
            OrchestrationTriggerAttribute trigger = parameter.GetCustomAttribute <OrchestrationTriggerAttribute>(inherit: false);

            if (trigger == null)
            {
                return(Task.FromResult <ITriggerBinding>(null));
            }

            // Priority for getting the name is [OrchestrationTrigger], [FunctionName], method name
            string name = trigger.Orchestration;

            if (string.IsNullOrEmpty(name))
            {
                MemberInfo method = context.Parameter.Member;
                name = method.GetCustomAttribute <FunctionNameAttribute>()?.Name ?? method.Name;
            }

            // The orchestration name defaults to the method name.
            var orchestratorName = new FunctionName(name);

            this.config.RegisterOrchestrator(orchestratorName, null);
            var binding = new OrchestrationTriggerBinding(this.config, parameter, orchestratorName);

            return(Task.FromResult <ITriggerBinding>(binding));
        }
Esempio n. 2
0
        public Task <ITriggerBinding> TryCreateAsync(TriggerBindingProviderContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            ParameterInfo parameter = context.Parameter;
            OrchestrationTriggerAttribute trigger = parameter.GetCustomAttribute <OrchestrationTriggerAttribute>(inherit: false);

            if (trigger == null)
            {
                return(Task.FromResult <ITriggerBinding>(null));
            }

            // The orchestration name defaults to the method name.
            string orchestrationName = trigger.Orchestration ?? parameter.Member.Name;

            // TODO: Support for per-function connection string and task hub names
            var binding = new OrchestrationTriggerBinding(
                this.config,
                parameter,
                orchestrationName,
                trigger.Version);

            return(Task.FromResult <ITriggerBinding>(binding));
        }