public ParameterDescriptor ToParameterDescriptor()
 {
     return(new ServiceBusTriggerParameterDescriptor
     {
         Name = _parameterName,
         EntityPath = _entityPath,
         DisplayHints = ServiceBusBinding.CreateParameterDisplayHints(_entityPath, true)
     });
 }
示例#2
0
        public ParameterDescriptor ToParameterDescriptor()
        {
            string entityPath = _queueName != null ?
                                _queueName : string.Format(CultureInfo.InvariantCulture, "{0}/Subscriptions/{1}", _topicName, _subscriptionName);

            return(new ServiceBusTriggerParameterDescriptor
            {
                Name = _parameterName,
                QueueName = _queueName,
                TopicName = _topicName,
                SubscriptionName = _subscriptionName,
                DisplayHints = ServiceBusBinding.CreateParameterDisplayHints(entityPath, true)
            });
        }
示例#3
0
        protected ParameterDescriptor ParseServiceBusTrigger(ServiceBusBindingMetadata trigger, Type triggerParameterType)
        {
            if (trigger == null)
            {
                throw new ArgumentNullException("trigger");
            }

            if (triggerParameterType == null)
            {
                throw new ArgumentNullException("triggerParameterType");
            }

            string       queueName        = trigger.QueueName;
            string       topicName        = trigger.TopicName;
            string       subscriptionName = trigger.SubscriptionName;
            AccessRights accessRights     = trigger.AccessRights;

            CustomAttributeBuilder attributeBuilder = null;

            if (!string.IsNullOrEmpty(topicName) && !string.IsNullOrEmpty(subscriptionName))
            {
                ConstructorInfo ctorInfo = typeof(ServiceBusTriggerAttribute).GetConstructor(new Type[] { typeof(string), typeof(string), typeof(AccessRights) });
                attributeBuilder = new CustomAttributeBuilder(ctorInfo, new object[] { topicName, subscriptionName, accessRights });
            }
            else if (!string.IsNullOrEmpty(queueName))
            {
                ConstructorInfo ctorInfo = typeof(ServiceBusTriggerAttribute).GetConstructor(new Type[] { typeof(string), typeof(AccessRights) });
                attributeBuilder = new CustomAttributeBuilder(ctorInfo, new object[] { queueName, accessRights });
            }
            else
            {
                throw new InvalidOperationException("Invalid ServiceBus trigger configuration.");
            }

            var attributes = new Collection <CustomAttributeBuilder>
            {
                attributeBuilder
            };

            if (!string.IsNullOrEmpty(trigger.Connection))
            {
                ServiceBusBinding.AddServiceBusAccountAttribute(attributes, trigger.Connection);
            }

            return(new ParameterDescriptor(trigger.Name, triggerParameterType, attributes));
        }