/// <summary> /// Registers a content handler to process response content /// </summary> /// <param name="contentType">MIME content type of the response content</param> /// <param name="deserializer">Deserializer to use to process content</param> public void AddHandler(string contentType, IDeserializer deserializer) { ContentHandlers[contentType] = deserializer; if (contentType == "*" || IsWildcardStructuredSuffixSyntax(contentType)) { return; } if (!AcceptTypes.Contains(contentType)) { AcceptTypes.Add(contentType); } // add Accept header based on registered deserializers var accepts = string.Join(", ", AcceptTypes.ToArray()); this.RemoveDefaultParameter("Accept"); this.AddDefaultParameter("Accept", accepts, ParameterType.HttpHeader); }
public string SelectFirstMatching(IEnumerable <string> candidates) { var exact = candidates.FirstOrDefault(x => AcceptTypes.Contains(x)); return(exact ?? (AcceptsAny() ? candidates.FirstOrDefault() : null)); }
public bool AcceptsAny() { return(AcceptTypes.Contains("*/*")); }
public bool AcceptsHtml() { return(AcceptTypes.Contains(MimeType.Html.ToString())); }
public bool CanConvert(FileConverterContext context) { return(TargetType == context.TargetType && AcceptTypes.Contains(context.InputType)); }