Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/aspnetwebstack.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/System.Web.Mvc/ExpressionUtil/HashCodeCombiner.cs')
-rw-r--r--src/System.Web.Mvc/ExpressionUtil/HashCodeCombiner.cs56
1 files changed, 56 insertions, 0 deletions
diff --git a/src/System.Web.Mvc/ExpressionUtil/HashCodeCombiner.cs b/src/System.Web.Mvc/ExpressionUtil/HashCodeCombiner.cs
new file mode 100644
index 00000000..37349bfc
--- /dev/null
+++ b/src/System.Web.Mvc/ExpressionUtil/HashCodeCombiner.cs
@@ -0,0 +1,56 @@
+using System.Collections;
+
+namespace System.Web.Mvc.ExpressionUtil
+{
+ // based on System.Web.Util.HashCodeCombiner
+ internal class HashCodeCombiner
+ {
+ private long _combinedHash64 = 0x1505L;
+
+ public int CombinedHash
+ {
+ get { return _combinedHash64.GetHashCode(); }
+ }
+
+ public void AddFingerprint(ExpressionFingerprint fingerprint)
+ {
+ if (fingerprint != null)
+ {
+ fingerprint.AddToHashCodeCombiner(this);
+ }
+ else
+ {
+ AddInt32(0);
+ }
+ }
+
+ public void AddEnumerable(IEnumerable e)
+ {
+ if (e == null)
+ {
+ AddInt32(0);
+ }
+ else
+ {
+ int count = 0;
+ foreach (object o in e)
+ {
+ AddObject(o);
+ count++;
+ }
+ AddInt32(count);
+ }
+ }
+
+ public void AddInt32(int i)
+ {
+ _combinedHash64 = ((_combinedHash64 << 5) + _combinedHash64) ^ i;
+ }
+
+ public void AddObject(object o)
+ {
+ int hashCode = (o != null) ? o.GetHashCode() : 0;
+ AddInt32(hashCode);
+ }
+ }
+}