本文整理汇总了C#中HashCodeCombiner.AddInt方法的典型用法代码示例。如果您正苦于以下问题:C# HashCodeCombiner.AddInt方法的具体用法?C# HashCodeCombiner.AddInt怎么用?C# HashCodeCombiner.AddInt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HashCodeCombiner
的用法示例。
在下文中一共展示了HashCodeCombiner.AddInt方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HashCombiner_Test_Int
public void HashCombiner_Test_Int()
{
var combiner1 = new HashCodeCombiner();
combiner1.AddInt(1234);
var combiner2 = new HashCodeCombiner();
combiner2.AddInt(1234);
Assert.AreEqual(combiner1.GetCombinedHashCode(), combiner2.GetCombinedHashCode());
combiner2.AddInt(1);
Assert.AreNotEqual(combiner1.GetCombinedHashCode(), combiner2.GetCombinedHashCode());
}
示例2: GetHashCode
public override int GetHashCode () {
HashCodeCombiner hashCodeCombiner = new HashCodeCombiner();
// We need non-randomized hash code for _varyByCustom
hashCodeCombiner.AddInt(StringUtil.GetNonRandomizedHashCode(_varyByCustom));
hashCodeCombiner.AddArray(_varyByParams);
hashCodeCombiner.AddArray(_varyByControls);
return hashCodeCombiner.CombinedHash32;
}
示例3: 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;
}
示例4: 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);
}