public Task <ITriggerBinding?> TryCreateAsync(TriggerBindingProviderContext context)
        {
            ParameterInfo parameter = context.Parameter;
            var           attribute = parameter.GetCustomAttribute <DaprTopicTriggerAttribute>(inherit: false);

            if (attribute == null)
            {
                return(Utils.NullTriggerBindingTask);
            }

            // Resolve names in pub/sub, topic, and route from settings
            if (!this.nameResolver.TryResolveWholeString(attribute.PubSubName, out var pubSubName))
            {
                pubSubName = attribute.PubSubName;
            }

            string topic = TriggerHelper.ResolveTriggerName(parameter, this.nameResolver, attribute.Topic);

            if (attribute.Route is null || !this.nameResolver.TryResolveWholeString(attribute.Route, out var route))
            {
                route = attribute.Route ?? topic;
            }

            if (!route.StartsWith("/"))
            {
                route = "/" + route;
            }

            return(Task.FromResult <ITriggerBinding?>(
                       new DaprTopicTriggerBinding(this.serviceListener, pubSubName, topic, route, parameter)));
        }
예제 #2
0
        public Task <ITriggerBinding?> TryCreateAsync(TriggerBindingProviderContext context)
        {
            ParameterInfo parameter = context.Parameter;
            var           attribute = parameter.GetCustomAttribute <DaprBindingTriggerAttribute>(inherit: false);

            if (attribute == null)
            {
                return(Utils.NullTriggerBindingTask);
            }

            string daprBindingName = TriggerHelper.ResolveTriggerName(parameter, this.nameResolver, attribute.BindingName);

            return(Task.FromResult <ITriggerBinding?>(
                       new DaprTriggerBinding(this.serviceListener, daprBindingName, parameter)));
        }
        public Task <ITriggerBinding?> TryCreateAsync(TriggerBindingProviderContext context)
        {
            ParameterInfo parameter = context.Parameter;
            var           attribute = parameter.GetCustomAttribute <DaprTopicTriggerAttribute>(inherit: false);

            if (attribute == null)
            {
                return(Utils.NullTriggerBindingTask);
            }

            string topic = TriggerHelper.ResolveTriggerName(parameter, this.nameResolver, attribute.Topic);

            // Verison 0.8 only support route to be the same as the topic name
            return(Task.FromResult <ITriggerBinding?>(
                       new DaprTopicTriggerBinding(this.serviceListener, topic, route: topic, parameter)));
        }