本文整理汇总了C#中System.Net.Http.Headers.CacheControlHeaderValue.Equals方法的典型用法代码示例。如果您正苦于以下问题:C# CacheControlHeaderValue.Equals方法的具体用法?C# CacheControlHeaderValue.Equals怎么用?C# CacheControlHeaderValue.Equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Net.Http.Headers.CacheControlHeaderValue
的用法示例。
在下文中一共展示了CacheControlHeaderValue.Equals方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CompareValues
private void CompareValues(CacheControlHeaderValue x, CacheControlHeaderValue y, bool areEqual)
{
Assert.Equal(areEqual, x.Equals(y));
Assert.Equal(areEqual, y.Equals(x));
}
示例2: Equals_CompareCollectionFieldsSet_MatchExpectation
public void Equals_CompareCollectionFieldsSet_MatchExpectation()
{
CacheControlHeaderValue cacheControl1 = new CacheControlHeaderValue();
CacheControlHeaderValue cacheControl2 = new CacheControlHeaderValue();
CacheControlHeaderValue cacheControl3 = new CacheControlHeaderValue();
CacheControlHeaderValue cacheControl4 = new CacheControlHeaderValue();
CacheControlHeaderValue cacheControl5 = new CacheControlHeaderValue();
CacheControlHeaderValue cacheControl6 = new CacheControlHeaderValue();
cacheControl1.NoCache = true;
cacheControl1.NoCacheHeaders.Add("token2");
Assert.False(cacheControl1.Equals(null), "Compare with 'null'");
cacheControl2.NoCache = true;
cacheControl2.NoCacheHeaders.Add("token1");
cacheControl2.NoCacheHeaders.Add("token2");
CompareValues(cacheControl1, cacheControl2, false);
cacheControl1.NoCacheHeaders.Add("token1");
CompareValues(cacheControl1, cacheControl2, true);
// Since NoCache and Private generate different hash codes, even if NoCacheHeaders and PrivateHeaders
// have the same values, the hash code will be different.
cacheControl3.Private = true;
cacheControl3.PrivateHeaders.Add("token2");
CompareValues(cacheControl1, cacheControl3, false);
cacheControl4.Private = true;
cacheControl4.PrivateHeaders.Add("token3");
CompareValues(cacheControl3, cacheControl4, false);
cacheControl5.Extensions.Add(new NameValueHeaderValue("custom"));
CompareValues(cacheControl1, cacheControl5, false);
cacheControl6.Extensions.Add(new NameValueHeaderValue("customN", "customV"));
cacheControl6.Extensions.Add(new NameValueHeaderValue("custom"));
CompareValues(cacheControl5, cacheControl6, false);
cacheControl5.Extensions.Add(new NameValueHeaderValue("customN", "customV"));
CompareValues(cacheControl5, cacheControl6, true);
}