GetHashCode() public method

public GetHashCode ( ) : int
return int
Example #1
0
 public override int GetHashCode()
 {
     return(base.GetHashCode() ^ NameValueHeaderValue.GetHashCode(parameters));
 }
Example #2
0
 public override int GetHashCode()
 {
     // The value string is case-insensitive.
     return(StringComparer.OrdinalIgnoreCase.GetHashCode(_value) ^ NameValueHeaderValue.GetHashCode(_parameters));
 }
        public void GetHashCode_ValuesUseDifferentValues_HashDiffersAccordingToRfc()
        {
            NameValueHeaderValue nameValue1 = new NameValueHeaderValue("text");
            NameValueHeaderValue nameValue2 = new NameValueHeaderValue("text");

            nameValue1.Value = null;
            nameValue2.Value = null;
            Assert.Equal(nameValue1.GetHashCode(), nameValue2.GetHashCode());

            nameValue1.Value = "token";
            nameValue2.Value = null;
            Assert.NotEqual(nameValue1.GetHashCode(), nameValue2.GetHashCode());

            nameValue1.Value = "token";
            nameValue2.Value = string.Empty;
            Assert.NotEqual(nameValue1.GetHashCode(), nameValue2.GetHashCode());

            nameValue1.Value = null;
            nameValue2.Value = string.Empty;
            Assert.Equal(nameValue1.GetHashCode(), nameValue2.GetHashCode());

            nameValue1.Value = "token";
            nameValue2.Value = "TOKEN";
            Assert.Equal(nameValue1.GetHashCode(), nameValue2.GetHashCode());

            nameValue1.Value = "token";
            nameValue2.Value = "token";
            Assert.Equal(nameValue1.GetHashCode(), nameValue2.GetHashCode());

            nameValue1.Value = "\"quoted string\"";
            nameValue2.Value = "\"QUOTED STRING\"";
            Assert.NotEqual(nameValue1.GetHashCode(), nameValue2.GetHashCode());

            nameValue1.Value = "\"quoted string\"";
            nameValue2.Value = "\"quoted string\"";
            Assert.Equal(nameValue1.GetHashCode(), nameValue2.GetHashCode());
        }
 public void GetHashCode_NameUseDifferentCasing_HashDiffersAccordingToRfc()
 {
     NameValueHeaderValue nameValue1 = new NameValueHeaderValue("text");
     NameValueHeaderValue nameValue2 = new NameValueHeaderValue("TEXT");
     Assert.Equal(nameValue1.GetHashCode(), nameValue2.GetHashCode());
 }
Example #5
0
 public override int GetHashCode()
 {
     // The dispositionType string is case-insensitive.
     return(dispositionType.ToLowerInvariant().GetHashCode() ^ NameValueHeaderValue.GetHashCode(parameters));
 }
Example #6
0
 /// <summary>充当 <see cref="T:System.Net.Http.Headers.ContentDispositionHeaderValue" /> 对象的哈希函数。</summary>
 /// <returns>当前对象的哈希代码。</returns>
 public override int GetHashCode()
 {
     return(StringComparer.OrdinalIgnoreCase.GetHashCode(this._dispositionType) ^ NameValueHeaderValue.GetHashCode(this._parameters));
 }