当前位置: 首页>>代码示例>>C#>>正文


C# CacheControlHeaderValue.Equals方法代码示例

本文整理汇总了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));
 }
开发者ID:noahfalk,项目名称:corefx,代码行数:5,代码来源:CacheControlHeaderValueTest.cs

示例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);
        }
开发者ID:noahfalk,项目名称:corefx,代码行数:43,代码来源:CacheControlHeaderValueTest.cs


注:本文中的System.Net.Http.Headers.CacheControlHeaderValue.Equals方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。