Ejemplo n.º 1
0
        private Guid GenerateDeterministicGuid(QueueId queueId)
        {
            // provider name hash code
            JenkinsHash jenkinsHash          = JenkinsHash.Factory.GetHashGenerator();
            int         providerNameGuidHash = (int)jenkinsHash.ComputeHash(providerName);

            // get queueId hash code
            uint queueIdHash = queueId.GetUniformHashCode();

            byte[] queIdHashByes = BitConverter.GetBytes(queueIdHash);
            short  s1            = BitConverter.ToInt16(queIdHashByes, 0);
            short  s2            = BitConverter.ToInt16(queIdHashByes, 2);

            // build guid tailing 8 bytes from providerNameGuidHash and queIdHashByes.
            var tail = new List <byte>();

            tail.AddRange(BitConverter.GetBytes(providerNameGuidHash));
            tail.AddRange(queIdHashByes);

            // make guid.
            // - First int is provider name hash
            // - Two shorts from queue Id hash
            // - 8 byte tail from provider name hash and queue Id hash.
            return(new Guid(providerNameGuidHash, s1, s2, tail.ToArray()));
        }