src/Serilog.Sinks.EventLog/Sinks/EventLog/EventIdHashProvider.cs
/// <summary>
/// Compute a 32-bit hash of the provided <paramref name="messageTemplate"/>. The
/// resulting hash value can be uses as an event id in lieu of transmitting the
/// full template string.
/// </summary>
/// <param name="messageTemplate">A message template.</param>
/// <returns>A 32-bit hash of the template.</returns>
Compute a 32-bit hash of the provided . The
resulting hash value can be uses as an event id in lieu of transmitting the
full template string.
Compute a 32 - bit hash of the provided . The resulting hash value can be uses as an event id in lieu of transmitting the full template string .
static int Compute(string messageTemplate)
        {
            if (messageTemplate == null) throw new ArgumentNullException(nameof(messageTemplate));
            unchecked
            {
                uint hash = 0;
                for (var i = 0; i < messageTemplate.Length; ++i)
                {
                    hash += messageTemplate[i];
                    hash += (hash << 10);
                    hash ^= (hash >> 6);
                }
                hash += (hash << 3);
                hash ^= (hash >> 11);
                hash += (hash << 15);
                return (ushort) hash;
            }
        }
static int Compute ( string messageTemplate ) { if ( messageTemplate == null ) throw new ArgumentNullException ( nameof ( messageTemplate ) ) ; unchecked { uint hash = 0 ; for ( var i = 0 ; i < messageTemplate . Length ; ++ i ) { hash += messageTemplate [ i ] ; hash += ( hash << 10 ) ; hash ^= ( hash >> 6 ) ; } hash += ( hash << 3 ) ; hash ^= ( hash >> 11 ) ; hash += ( hash << 15 ) ; return ( ushort ) hash ; } }
Compute a 32-bit hash of the provided .
Compute a 32 - bit hash of the provided .
// Jenkins one-at-a-time https://en.wikipedia.org/wiki/Jenkins_hash_function //even though the api is type int, eventID must be between 0 and 65535 //https://msdn.microsoft.com/en-us/library/d3159s0c(v=vs.110).aspx
A 32-bit hash of the template.
A 32 - bit hash of the template .
messageTemplate
string
A message template.
A message template .