protected override Collection <HttpOperationHandler> OnCreateRequestHandlers(ServiceEndpoint endpoint, HttpOperationDescription operation)
            {
                var handlers = this.innerFactory != null?
                               this.innerFactory.CreateRequestHandlers(endpoint, operation) :
                                   base.OnCreateRequestHandlers(endpoint, operation);

                handlers.Add(new UriMultiValueTemplateHandler(endpoint.Address.Uri, operation.GetUriTemplate()));

                return(handlers);
            }
Esempio n. 2
0
 protected override object[] OnHandle(object[] input)
 {
     var request           = (HttpRequestMessage)input[0];
     var uriTemplate       = _httpOperationDescription.GetUriTemplate();
     var uriTemplateMatch  = uriTemplate.Match(_baseAddress, request.RequestUri);
     var validationResults = new List <ValidationResult>();
     //Bind the values from uriTemplateMatch.BoundVariables to a model
     //Do the validation with Validator.TryValidateObject and add the results to validationResults
     //Throw a exception with BadRequest http status code and add the validationResults to the message
     //Return an object array with instances of the types returned from the OnGetOutputParmeters with the bounded values
 }
 protected override object[] OnHandle(object[] input)
 {
     var request           = (HttpRequestMessage)input[0];
     var uriTemplate       = _httpOperationDescription.GetUriTemplate();
     var uriTemplateMatch  = uriTemplate.Match(_baseAddress, request.RequestUri);
     var validationResults = new List <ValidationResult>();
     //Bind the values from uriTemplateMatch.BoundVariables to a model
     //Do the validation with Validator.TryValidateObject and add the results to validationResults
     //Throw a exception with BadRequest http status code and add the validationResults to the message
     //Return the bound model if no validation errors occured
 }
Esempio n. 4
0
        public static HttpParameterDescription GetBodyParameter(
            this HttpOperationDescription operation)
        {
            if (operation == null)
            {
                throw new ArgumentNullException("operation");
            }

            UriTemplate          template     = operation.GetUriTemplate();
            IEnumerable <string> uriVariables = template.PathSegmentVariableNames
                                                .Concat(template.QueryValueVariableNames);

            return(operation.InputParameters
                   .Where(p =>
                          !uriVariables.Contains(p.Name, StringComparer.OrdinalIgnoreCase))
                   .FirstOrDefault());
        }
        /// <summary>
        /// Called when the ordered collection of <see cref="HttpOperationHandler"/> instances is being created for 
        /// the given <paramref name="operation"/>.  Can be overridden in a derived class to customize the 
        /// collection of <see cref="HttpOperationHandler"/> instances returned. 
        /// </summary>
        /// <remarks>
        /// The base implemenation returns the standard request <see cref="HttpOperationHandler"/> instances for the given
        /// operation.
        /// </remarks>
        /// <param name="endpoint">The service endpoint.</param>
        /// <param name="operation">The description of the service operation.</param>
        /// <returns>
        /// The ordered collection of <see cref="HttpOperationHandler"/> instances to use when handling 
        /// <see cref="HttpRequestMessage"/> instances for the given operation.
        /// </returns>
        protected virtual Collection<HttpOperationHandler> OnCreateRequestHandlers(ServiceEndpoint endpoint, HttpOperationDescription operation)
        {
            if (endpoint == null)
            {
                throw Fx.Exception.ArgumentNull("endpoint");
            }

            if (operation == null)
            {
                throw Fx.Exception.ArgumentNull("operation");
            }

            Collection<HttpOperationHandler> requestHandlers = new Collection<HttpOperationHandler>();

            HttpMethod method = operation.GetHttpMethod();
            UriTemplate uriTemplate = operation.GetUriTemplate();
            string[] uriTemplateParameterNames = uriTemplate.PathSegmentVariableNames.Concat(uriTemplate.QueryValueVariableNames).ToArray();
            if (uriTemplateParameterNames.Length > 0)
            {
                requestHandlers.Add(new UriTemplateHandler(endpoint.Address.Uri, uriTemplate));
            }

            if (method != HttpMethod.Get && method != HttpMethod.Head)
            {
                HttpParameter requestContentParameter = GetRequestContentHandler(operation, uriTemplateParameterNames);
                if (requestContentParameter != null)
                {
                    requestContentParameter.IsContentParameter = true;
                    requestHandlers.Add(new RequestContentHandler(requestContentParameter, this.Formatters));

                    SetXmlAndJsonSerializers(operation, requestContentParameter, this.Formatters);
                }
            }

            return requestHandlers;
        }
			protected override Collection<HttpOperationHandler> OnCreateRequestHandlers(ServiceEndpoint endpoint, HttpOperationDescription operation)
			{
				var handlers = this.innerFactory != null ?
					this.innerFactory.CreateRequestHandlers(endpoint, operation) :
					base.OnCreateRequestHandlers(endpoint, operation);

				handlers.Add(new UriMultiValueTemplateHandler(endpoint.Address.Uri, operation.GetUriTemplate()));

				return handlers;
			}