mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 03:25:23 +08:00
26 lines
737 B
C#
26 lines
737 B
C#
using System;
|
|
|
|
namespace Orchard.Utility {
|
|
/// <summary>
|
|
/// Compute an (almost) unique hash value from various sources.
|
|
/// This allows computing hash keys that are easily storable
|
|
/// and comparable from heterogenous components.
|
|
/// </summary>
|
|
public class Hash {
|
|
private long _hash;
|
|
|
|
public string Value { get { return _hash.ToString(); } }
|
|
|
|
public void AddString(string value) {
|
|
if ( string.IsNullOrEmpty(value) )
|
|
return;
|
|
_hash += value.GetHashCode();
|
|
}
|
|
|
|
public void AddTypeReference(Type type) {
|
|
AddString(type.AssemblyQualifiedName);
|
|
AddString(type.FullName);
|
|
}
|
|
}
|
|
}
|