示例#1
0
 /// <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 != "*")
     {
         AcceptTypes.Add(contentType);
     }
 }
示例#2
0
 public void AddHandler(string contentType, IDeserializer deserializer)
 {
     ContentHandlers[contentType] = deserializer;
     if (contentType != "*")
     {
         AcceptTypes.Add(contentType);
         string value = string.Join(", ", AcceptTypes.ToArray());
         this.RemoveDefaultParameter("Accept");
         this.AddDefaultParameter("Accept", value, ParameterType.HttpHeader);
     }
 }
示例#3
0
 /// <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 != "*")
     {
         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);
     }
 }
示例#4
0
        public void AddHandler(string contentType, IDeserializer deserializer)
        {
            ContentHandlers[contentType] = deserializer;

            if (contentType == "*" || StructuredSyntaxSuffixWildcardRegex.IsMatch(contentType))
            {
                return;
            }

            AcceptTypes.Add(contentType);
            var accepts = string.Join(", ", AcceptTypes);

            RemoveDefaultParameter("Accept");
            AddDefaultParameter("Accept", accepts, ParameterType.HttpHeader);
        }
示例#5
0
        /// <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 == "*" || structuredSyntaxSuffixWildcardRegex.IsMatch(contentType))
            {
                return;
            }

            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);
        }
        /// <summary>
        ///     Registers a content handler to process response content
        /// </summary>
        /// <param name="contentType">MIME content type of the response content</param>
        /// <param name="deserializerFactory">Deserializer to use to process content</param>
        public void AddHandler(string contentType, Func <IDeserializer> deserializerFactory)
        {
            ContentHandlers[contentType] = deserializerFactory;

            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);
        }