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


C# HashCodeCombiner.AddCaseInsensitiveString方法代码示例

本文整理汇总了C#中HashCodeCombiner.AddCaseInsensitiveString方法的典型用法代码示例。如果您正苦于以下问题:C# HashCodeCombiner.AddCaseInsensitiveString方法的具体用法?C# HashCodeCombiner.AddCaseInsensitiveString怎么用?C# HashCodeCombiner.AddCaseInsensitiveString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在HashCodeCombiner的用法示例。


在下文中一共展示了HashCodeCombiner.AddCaseInsensitiveString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: HashCombiner_Test_String

        public void HashCombiner_Test_String()
        {
            var combiner1 = new HashCodeCombiner();
            combiner1.AddCaseInsensitiveString("Hello");

            var combiner2 = new HashCodeCombiner();
            combiner2.AddCaseInsensitiveString("hello");

            Assert.AreEqual(combiner1.GetCombinedHashCode(), combiner2.GetCombinedHashCode());

            combiner2.AddCaseInsensitiveString("world");

            Assert.AreNotEqual(combiner1.GetCombinedHashCode(), combiner2.GetCombinedHashCode());
        }
开发者ID:joonhwan,项目名称:NPoco,代码行数:14,代码来源:HashCodeCombinerTests.cs

示例2: ComputeVaryCacheKey

    private string ComputeVaryCacheKey(HashCodeCombiner combinedHashCode,
        ControlCachedVary cachedVary) {

        // Add something to the has to differentiate it from the non-vary hash.
        // This is needed in case this method doesn't add anything else to the hash (VSWhidbey 194199)
        combinedHashCode.AddInt(1);

        // Get the request value collection
        NameValueCollection reqValCollection;
        HttpRequest request = Page.Request;
        if (request != null && request.HttpVerb == HttpVerb.POST) {
            // 


            reqValCollection = new NameValueCollection(request.QueryString);
            reqValCollection.Add(request.Form);
        }
        else {
            // Use the existing value if possible to avoid recreating a NameValueCollection
            reqValCollection = Page.RequestValueCollection;
            // If it's not set, get it based on the method
            if (reqValCollection == null) {
                reqValCollection = Page.GetCollectionBasedOnMethod(true /*dontReturnNull*/);
            }
        }

        if (cachedVary._varyByParams != null) {

            ICollection itemsToUseForHashCode;

            // If '*' was specified, use all the items in the request collection.
            // Otherwise, use only those specified.
            if (cachedVary._varyByParams.Length == 1 && cachedVary._varyByParams[0] == "*")
                itemsToUseForHashCode = reqValCollection;
            else
                itemsToUseForHashCode = cachedVary._varyByParams;

            // Add the items and their values to compute the hash code
            foreach (string varyByParam in itemsToUseForHashCode) {

                // Note: we use to ignore certain system fields here (like VIEWSTATE), but decided
                // not to for consistency with pahe output caching (VSWhidbey 196267, 479252)

                combinedHashCode.AddCaseInsensitiveString(varyByParam);
                string val = reqValCollection[varyByParam];
                if (val != null)
                    combinedHashCode.AddObject(val);
            }
        }

        if (cachedVary._varyByControls != null) {

            // Prepend them with a prefix to make them fully qualified
            string prefix;
            if (NamingContainer == Page) {
                // No prefix if it's the page
                prefix = String.Empty;
            }
            else {
                prefix = NamingContainer.UniqueID;
                Debug.Assert(!String.IsNullOrEmpty(prefix));
                prefix += IdSeparator;
            }

            prefix += _ctrlID + IdSeparator;

            // Add all the relative vary params and their values to the hash code
            foreach (string varyByParam in cachedVary._varyByControls) {

                string temp = prefix + varyByParam.Trim();
                combinedHashCode.AddCaseInsensitiveString(temp);
                string val = reqValCollection[temp];
                if (val != null)
                    combinedHashCode.AddObject(reqValCollection[temp]);
            }
        }

        if (cachedVary._varyByCustom != null) {
            string customString = Context.ApplicationInstance.GetVaryByCustomString(
                Context, cachedVary._varyByCustom);
            if (customString != null)
                combinedHashCode.AddObject(customString);
        }

        return CacheInternal.PrefixPartialCachingControl + combinedHashCode.CombinedHashString;
    }
开发者ID:uQr,项目名称:referencesource,代码行数:86,代码来源:PartialCachingControl.cs

示例3: ComputeVaryCacheKey

 private string ComputeVaryCacheKey(HashCodeCombiner combinedHashCode, ControlCachedVary cachedVary)
 {
     combinedHashCode.AddInt(1);
     NameValueCollection requestValueCollection = this.Page.RequestValueCollection;
     if (requestValueCollection == null)
     {
         requestValueCollection = this.Page.GetCollectionBasedOnMethod(true);
     }
     if (cachedVary._varyByParams != null)
     {
         ICollection is2;
         if ((cachedVary._varyByParams.Length == 1) && (cachedVary._varyByParams[0] == "*"))
         {
             is2 = requestValueCollection;
         }
         else
         {
             is2 = cachedVary._varyByParams;
         }
         foreach (string str in is2)
         {
             combinedHashCode.AddCaseInsensitiveString(str);
             string s = requestValueCollection[str];
             if (s != null)
             {
                 combinedHashCode.AddObject(s);
             }
         }
     }
     if (cachedVary._varyByControls != null)
     {
         string str3;
         if (this.NamingContainer == this.Page)
         {
             str3 = string.Empty;
         }
         else
         {
             str3 = this.NamingContainer.UniqueID + base.IdSeparator;
         }
         str3 = str3 + this._ctrlID + base.IdSeparator;
         foreach (string str4 in cachedVary._varyByControls)
         {
             string str5 = str3 + str4.Trim();
             combinedHashCode.AddCaseInsensitiveString(str5);
             if (requestValueCollection[str5] != null)
             {
                 combinedHashCode.AddObject(requestValueCollection[str5]);
             }
         }
     }
     if (cachedVary._varyByCustom != null)
     {
         string varyByCustomString = this.Context.ApplicationInstance.GetVaryByCustomString(this.Context, cachedVary._varyByCustom);
         if (varyByCustomString != null)
         {
             combinedHashCode.AddObject(varyByCustomString);
         }
     }
     return ("l" + combinedHashCode.CombinedHashString);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:61,代码来源:BasePartialCachingControl.cs


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