URSA.Web.Http.HeaderCollection.Set C# (CSharp) Метод

Set() публичный Метод

Sets a new header.
If the header already exists, it is replaced with the new one.
public Set ( Header header ) : Header
header Header Header to be set.
Результат Header
        public Header Set(Header header)
        {
            if (header == null)
            {
                throw new ArgumentNullException("header");
            }

            return _headers[header.Name] = header;
        }

Same methods

HeaderCollection::Set ( string name, string value ) : Header

Usage Example

Пример #1
0
        public void it_should_set_a_header()
        {
            HeaderCollection headers = new HeaderCollection();
            headers.Set(new Header("Header1", new[] { new HeaderValue("Value1", new HeaderParameter("Parameter1", "ParameterValue1")) }));
            headers.Set(new Header("Header1", "Value2"));

            headers.Count.Should().Be(1);
            headers["Header1"].Values.Count.Should().Be(1);
            headers["Header1"].Values.First().Parameters.Count.Should().Be(0);
        }