Example #1
0
        protected ParameterDescriptor ParseQueueTrigger(QueueBindingMetadata trigger, Type triggerParameterType)
        {
            if (trigger == null)
            {
                throw new ArgumentNullException("trigger");
            }
            if (triggerParameterType == null)
            {
                throw new ArgumentNullException("triggerParameterType");
            }

            ConstructorInfo        ctorInfo         = typeof(QueueTriggerAttribute).GetConstructor(new Type[] { typeof(string) });
            string                 queueName        = trigger.QueueName;
            CustomAttributeBuilder attributeBuilder = new CustomAttributeBuilder(ctorInfo, new object[] { queueName });

            string parameterName = trigger.Name;
            var    attributes    = new Collection <CustomAttributeBuilder>
            {
                attributeBuilder
            };

            if (!string.IsNullOrEmpty(trigger.Connection))
            {
                FunctionBinding.AddStorageAccountAttribute(attributes, trigger.Connection);
            }

            return(new ParameterDescriptor(parameterName, triggerParameterType, attributes));
        }
        public QueueBinding(ScriptHostConfiguration config, QueueBindingMetadata metadata, FileAccess access) : 
            base(config, metadata, access)
        {
            if (string.IsNullOrEmpty(metadata.QueueName))
            {
                throw new ArgumentException("The queue name cannot be null or empty.");
            }

            QueueName = metadata.QueueName;
            _queueNameBindingTemplate = BindingTemplate.FromString(QueueName);
        }
        public void GenerateQueueTriggerFunction()
        {
            QueueBindingMetadata trigger = new QueueBindingMetadata
            {
                Type = BindingType.QueueTrigger,
                QueueName = "test"
            };
            MethodInfo method = GenerateMethod(trigger);

            VerifyCommonProperties(method);

            // verify trigger parameter
            ParameterInfo parameter = method.GetParameters()[0];
            Assert.Equal("input", parameter.Name);
            Assert.Equal(typeof(string), parameter.ParameterType);
            QueueTriggerAttribute attribute = parameter.GetCustomAttribute<QueueTriggerAttribute>();
            Assert.Equal("test", attribute.QueueName);
        }
Example #4
0
        protected ParameterDescriptor ParseQueueTrigger(QueueBindingMetadata trigger, Type triggerParameterType = null)
        {
            if (triggerParameterType == null)
            {
                triggerParameterType = typeof(string);
            }

            ConstructorInfo        ctorInfo         = typeof(QueueTriggerAttribute).GetConstructor(new Type[] { typeof(string) });
            string                 queueName        = trigger.QueueName;
            CustomAttributeBuilder attributeBuilder = new CustomAttributeBuilder(ctorInfo, new object[] { queueName });

            string parameterName = trigger.Name;
            var    attributes    = new Collection <CustomAttributeBuilder>
            {
                attributeBuilder
            };

            return(new ParameterDescriptor(parameterName, triggerParameterType, attributes));
        }
        protected ParameterDescriptor ParseQueueTrigger(QueueBindingMetadata trigger, Type triggerParameterType = null)
        {
            if (triggerParameterType == null)
            {
                triggerParameterType = typeof(string);
            }

            ConstructorInfo ctorInfo = typeof(QueueTriggerAttribute).GetConstructor(new Type[] { typeof(string) });
            string queueName = trigger.QueueName;
            CustomAttributeBuilder attributeBuilder = new CustomAttributeBuilder(ctorInfo, new object[] { queueName });

            string parameterName = trigger.Name;
            var attributes = new Collection<CustomAttributeBuilder>
            {
                attributeBuilder
            };
            return new ParameterDescriptor(parameterName, triggerParameterType, attributes);
        }
        protected ParameterDescriptor ParseQueueTrigger(QueueBindingMetadata trigger, Type triggerParameterType = null)
        {
            if (trigger == null)
            {
                throw new ArgumentNullException("trigger");
            }

            if (triggerParameterType == null)
            {
                triggerParameterType = typeof(string);
            }

            ConstructorInfo ctorInfo = typeof(QueueTriggerAttribute).GetConstructor(new Type[] { typeof(string) });
            string queueName = trigger.QueueName;
            CustomAttributeBuilder attributeBuilder = new CustomAttributeBuilder(ctorInfo, new object[] { queueName });

            string parameterName = trigger.Name;
            var attributes = new Collection<CustomAttributeBuilder>
            {
                attributeBuilder
            };

            if (!string.IsNullOrEmpty(trigger.Connection))
            {
                FunctionBinding.AddStorageAccountAttribute(attributes, trigger.Connection);
            }

            return new ParameterDescriptor(parameterName, triggerParameterType, attributes);
        }