public CustomMessageFormatter(HttpOperationDescription httpOperation) { if (httpOperation == null) { throw new ArgumentNullException("httpOperation"); } if (httpOperation.InputParameters.Count == 1 && httpOperation.InputParameters[0].ParameterType == typeof(HttpRequestMessage)) { this.hasRequestMessage = true; } else if (httpOperation.InputParameters.Count != 0) { throw new NotSupportedException( "The MessageFormatter only supports a single optional input parameter of type 'HttpRequestMessage'."); } if (httpOperation.OutputParameters.Count > 0) { throw new NotSupportedException( "The MessageFormatter only does not support outputt parameters."); } if (httpOperation.ReturnValue.ParameterType == typeof(HttpResponseMessage)) { this.hasResponseMessage = true; } else if (httpOperation.ReturnValue.ParameterType != typeof(void)) { throw new NotSupportedException( "The MessageFormatter only supports an optional return type of 'HttpResponseMessage'."); } }
public WebLinkingProcessor(WebLinksRegistry registry, HttpOperationDescription httpOperationDescription, MediaTypeProcessorMode mode) { _registry = registry; _method = httpOperationDescription.SyncMethod ?? httpOperationDescription.BeginMethod; _mode = mode; }
public void RegisterResponseProcessorsForOperation(HttpOperationDescription operation, IList<Processor> processors, MediaTypeProcessorMode mode) { if (_inner != null) { _inner.RegisterResponseProcessorsForOperation(operation, processors, mode); } processors.Add(new WebLinkingProcessor(LinksRegistry, operation, mode)); }
public DataValidationProcessor(HttpOperationDescription oper) { _oper = oper; _inputArgs = _oper.InputParameters .Where(p => p.ParameterType != typeof (HttpRequestMessage) && p.ParameterType != typeof (HttpResponseMessage) && p.ParameterType != typeof (DataValidationResult)) .ToArray(); }
public RequestLoggingProcessor(HttpOperationDescription oper) { Trace.AutoFlush = true; _oper = oper; _inputArgs = _oper.InputParameters .Where(p => p.ParameterType != typeof(HttpRequestMessage) && p.ParameterType != typeof(HttpResponseMessage)) .Select(p => new ProcessorArgument(p.Name, p.ParameterType)).ToArray(); }
public XmlProcessor(HttpOperationDescription operation, MediaTypeProcessorMode mode) : base(operation, mode) { var returnType = operation.ReturnValue; //IQueryable support if (operation.Behaviors.Contains(typeof(QueryCompositionAttribute))) { usesQueryComposition = true; var queryCompositionItemType = operation.ReturnValue.ParameterType.GetGenericArguments()[0]; queryCompositionType = typeof(List<>).MakeGenericType(queryCompositionItemType); } }
public FormUrlEncodedProcessor(HttpOperationDescription operation, MediaTypeProcessorMode mode) : base(operation, MediaTypeProcessorMode.Request) { if (mode == MediaTypeProcessorMode.Response) { throw new ArgumentException("mode", "This processor cannot be used in the response"); } if (this.Parameter != null) { this.parameterType = Parameter.ParameterType; this.isJsonValueParameter = typeof(JsonValue).IsAssignableFrom(this.parameterType); } }
public JsonProcessor(HttpOperationDescription operation, MediaTypeProcessorMode mode) : base(operation, mode) { if (this.Parameter != null) { this.parameterType = this.Parameter.ParameterType; this.isJsonValueParameter = typeof(JsonValue).IsAssignableFrom(this.parameterType); } //IQueryable support if (operation.Behaviors.Contains(typeof(QueryCompositionAttribute))) { usesQueryComposition = true; var queryCompositionItemType = operation.ReturnValue.ParameterType.GetGenericArguments()[0]; queryCompositionType = typeof(List<>).MakeGenericType(queryCompositionItemType); } }
protected MediaTypeProcessor(HttpOperationDescription operation, MediaTypeProcessorMode mode) { if (mode == MediaTypeProcessorMode.Request) { this.Parameter = operation.GetBodyParameter(); } else { this.Parameter = operation.ReturnValue; } if (this.Parameter != null && (this.Parameter.ParameterType == typeof(HttpRequestMessage) || this.Parameter.ParameterType == typeof(HttpResponseMessage))) { this.ignore = true; this.Parameter = null; } this.mode = mode; }
/// <summary> /// Retrieves the appropriate <see cref="MessagePartDescriptionCollection"/> for the current instance. /// If the synchronized <see cref="OperationDescription"/> does not have the corresponding collection, /// this method will create a default <see cref="MessageDescription"/> element so that the collection exists. /// </summary> /// <returns>The <see cref="MessagePartDescriptionCollection"/>.</returns> private MessagePartDescriptionCollection GetOrCreateMessagePartDescriptionCollection() { Debug.Assert(this.IsSynchronized, "This method cannot be called for unsynchronized collections"); MessagePartDescriptionCollection mpdColl = this.MessagePartDescriptionCollection; if (mpdColl == null) { OperationDescription od = this.operationDescription; int messageIndex = this.isOutputCollection ? 1 : 0; if (od.Messages.Count <= messageIndex) { HttpOperationDescription.CreateMessageDescriptionIfNecessary(od, messageIndex); } Debug.Assert(od.Messages.Count > messageIndex, "CreateMessageDescription should have created Message element"); mpdColl = od.Messages[messageIndex].Body.Parts; } Debug.Assert(mpdColl != null, "return value can never be null"); return(mpdColl); }
public HttpPipelineFormatter(Processor[] requestProcessors, Processor[] responseProcessors, HttpOperationDescription operationDescription, MessageProperties messageProperties = null) { this.messageProperties = messageProperties; if (requestProcessors == null) { throw new ArgumentNullException("requestProcessors"); } this.requestProcessors = requestProcessors; if (responseProcessors == null) { throw new ArgumentNullException("responseProcessors"); } if (operationDescription == null) { throw new ArgumentNullException("operationDescription"); } this.responseProcessors = responseProcessors; this.requestProcessors = requestProcessors; this.OperationDescription = operationDescription; }
public PlainTextProcessor(HttpOperationDescription operation, MediaTypeProcessorMode mode) : base(operation, mode) { }
public ImageFromTextMediaProcessor(HttpOperationDescription operation, MediaTypeProcessorMode mode) : base(operation,mode) { }
public void RegisterRequestProcessorsForOperation(HttpOperationDescription operation, IList<Processor> processors, MediaTypeProcessorMode mode) { processors.Add(new FormUrlEncodedProcessor(operation, mode)); }
public void RegisterResponseProcessorsForOperation(HttpOperationDescription operation, IList<Processor> processors, MediaTypeProcessorMode mode) { // No response processors }
public void RegisterRequestProcessorsForOperation(HttpOperationDescription operation, IList<Processor> processors, MediaTypeProcessorMode mode) { processors.Add(new DataValidationProcessor(operation)); }
public void RegisterResponseProcessorsForOperation(HttpOperationDescription operation, IList<Processor> processors, MediaTypeProcessorMode mode) { operation.EnableAsync(); }
public void RegisterRequestProcessorsForOperation(HttpOperationDescription operation, IList<Processor> processors, MediaTypeProcessorMode mode) { }
public void RegisterResponseProcessorsForOperation(HttpOperationDescription operation, IList<Processor> processors, MediaTypeProcessorMode mode) { throw new NotImplementedException(); }
public void RegisterResponseProcessorsForOperation(HttpOperationDescription operation, IList<Processor> processors, MediaTypeProcessorMode mode) { processors.Add(new JsonProcessor(operation, mode)); }
public void RegisterResponseProcessorsForOperation(HttpOperationDescription operation, IList<Processor> processors, MediaTypeProcessorMode mode) { this.responseProcessors(operation, processors, mode); }
public void RegisterResponseProcessorsForOperation(System.ServiceModel.Description.HttpOperationDescription operation, IList <System.ServiceModel.Dispatcher.Processor> processors, MediaTypeProcessorMode mode) { processors.Add(new JsonProcessor(operation, mode)); }
private static string GetDefaultWebGetUriTemplate(HttpOperationDescription operation) { StringBuilder builder = new StringBuilder(operation.Name); builder.Append("?"); foreach (HttpParameterDescription parameter in operation.InputParameters) { string name = parameter.Name; builder.Append(name); builder.Append("={"); builder.Append(name); builder.Append("}&"); } builder.Remove(builder.Length - 1, 1); return builder.ToString(); }