Class HashCodeCombiner
Used to create a .NET HashCode from multiple objects.
Inheritance
Namespace: Umbraco.Cms.Core
Assembly: Umbraco.Core.dll
Syntax
public class HashCodeCombiner
Remarks
.Net has a class the same as this: System.Web.Util.HashCodeCombiner and of course it works for all sorts of things which we've not included here as we just need a quick easy class for this in order to create a unique hash of directories/files to see if they have changed. NOTE: It's probably best to not relying on the hashing result across AppDomains! If you need a constant/reliable hash value between AppDomains use SHA1. This is perfect for hashing things in a very fast way for a single AppDomain.
Constructors
View SourceHashCodeCombiner()
Declaration
public HashCodeCombiner()
Methods
View SourceAddCaseInsensitiveString(string)
Adds a string value to the combined hash using case-insensitive comparison.
Declaration
public void AddCaseInsensitiveString(string s)
Parameters
| Type | Name | Description |
|---|---|---|
| string | s | The string value to add. |
AddDateTime(DateTime)
Adds a DateTime value to the combined hash.
Declaration
public void AddDateTime(DateTime d)
Parameters
| Type | Name | Description |
|---|---|---|
| DateTime | d | The DateTime value to add. |
AddFile(FileInfo)
Adds a file to the combined hash.
Declaration
public void AddFile(FileInfo f)
Parameters
| Type | Name | Description |
|---|---|---|
| FileInfo | f | The file to add. |
AddFileSystemItem(FileSystemInfo)
Adds a file system item (file or directory) to the combined hash.
Declaration
public void AddFileSystemItem(FileSystemInfo f)
Parameters
| Type | Name | Description |
|---|---|---|
| FileSystemInfo | f | The file system item to add. |
Remarks
This method adds the full name, creation time, last write time, and (for files) the length. For directories, all contained files and subdirectories are recursively added.
AddFolder(DirectoryInfo)
Adds a folder and all its contents to the combined hash.
Declaration
public void AddFolder(DirectoryInfo d)
Parameters
| Type | Name | Description |
|---|---|---|
| DirectoryInfo | d | The directory to add. |
AddInt(int)
Adds an integer value to the combined hash.
Declaration
public void AddInt(int i)
Parameters
| Type | Name | Description |
|---|---|---|
| int | i | The integer value to add. |
AddObject(object)
Adds an object's hash code to the combined hash.
Declaration
public void AddObject(object o)
Parameters
| Type | Name | Description |
|---|---|---|
| object | o | The object to add. |
AddString(string)
Adds a string value to the combined hash using invariant culture.
Declaration
public void AddString(string s)
Parameters
| Type | Name | Description |
|---|---|---|
| string | s | The string value to add. |
GetCombinedHashCode()
Returns the hex code of the combined hash code
Declaration
public string GetCombinedHashCode()
Returns
| Type | Description |
|---|---|
| string |