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

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

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

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

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

            // The activity name defaults to the method name.
            var activityName = new FunctionName(name);

            this.durableTaskConfig.RegisterActivity(activityName, null);
            var binding = new ActivityTriggerBinding(this, parameter, trigger, activityName);

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

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

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

            // The activity name defaults to the method name.
            string activityName = trigger.Activity ?? parameter.Member.Name;

            var binding = new ActivityTriggerBinding(
                this,
                parameter,
                trigger,
                activityName,
                trigger.Version);

            return(Task.FromResult <ITriggerBinding>(binding));
        }
 public ActivityTriggerBinding(
     ActivityTriggerAttributeBindingProvider parent,
     ParameterInfo parameterInfo,
     ActivityTriggerAttribute attribute,
     FunctionName activity)
 {
     this.parent        = parent;
     this.parameterInfo = parameterInfo;
     this.attribute     = attribute;
     this.activityName  = activity;
 }
 public ActivityTriggerBinding(
     ActivityTriggerAttributeBindingProvider parent,
     ParameterInfo parameterInfo,
     ActivityTriggerAttribute attribute,
     string activityName,
     string activityVersion)
 {
     this.parent          = parent;
     this.parameterInfo   = parameterInfo;
     this.attribute       = attribute;
     this.activityName    = activityName;
     this.activityVersion = activityVersion;
 }
Beispiel #5
0
 public ActivityTriggerBinding(
     ActivityTriggerAttributeBindingProvider parent,
     ParameterInfo parameterInfo,
     ActivityTriggerAttribute attribute,
     FunctionName activity,
     DurableTaskExtension durableTaskConfig)
 {
     this.parent            = parent;
     this.parameterInfo     = parameterInfo;
     this.attribute         = attribute;
     this.activityName      = activity;
     this.contract          = GetBindingDataContract(parameterInfo);
     this.durableTaskConfig = durableTaskConfig;
 }