Microsoft.Azure.WebJobs.Script.Binding.HttpTriggerAttributeBindingProvider.HttpTriggerBinding.HttpTriggerBinding C# (CSharp) Méthode

HttpTriggerBinding() public méthode

public HttpTriggerBinding ( HttpTriggerAttribute attribute, ParameterInfo parameter, bool isUserTypeBinding ) : System
attribute HttpTriggerAttribute
parameter System.Reflection.ParameterInfo
isUserTypeBinding bool
Résultat System
            public HttpTriggerBinding(HttpTriggerAttribute attribute, ParameterInfo parameter, bool isUserTypeBinding)
            {
                _parameter = parameter;
                _isUserTypeBinding = isUserTypeBinding;

                Dictionary<string, Type> aggregateDataContract = new Dictionary<string, Type>(StringComparer.OrdinalIgnoreCase);
                if (_isUserTypeBinding)
                {
                    // Create the BindingDataProvider from the user Type. The BindingDataProvider
                    // is used to define the binding parameters that the binding exposes to other
                    // bindings (i.e. the properties of the POCO can be bound to by other bindings).
                    // It is also used to extract the binding data from an instance of the Type.
                    _bindingDataProvider = BindingDataProvider.FromType(parameter.ParameterType);
                    if (_bindingDataProvider.Contract != null)
                    {
                        aggregateDataContract.AddRange(_bindingDataProvider.Contract);
                    }
                }

                // add any route parameters to the contract
                if (!string.IsNullOrEmpty(attribute.RouteTemplate))
                {
                    var routeParameters = _httpRouteFactory.GetRouteParameters(attribute.RouteTemplate);
                    var parameters = ((MethodInfo)parameter.Member).GetParameters().ToDictionary(p => p.Name, p => p.ParameterType, StringComparer.OrdinalIgnoreCase);
                    foreach (string parameterName in routeParameters)
                    {
                        // don't override if the contract already includes a name
                        if (!aggregateDataContract.ContainsKey(parameterName))
                        {
                            // if there is a method parameter mapped to this parameter
                            // derive the Type from that
                            Type type;
                            if (!parameters.TryGetValue(parameterName, out type))
                            {
                                type = typeof(string);
                            }
                            aggregateDataContract[parameterName] = type;
                        }
                    }
                }

                _bindingDataContract = aggregateDataContract;
            }