NServiceBus.DeterministicGuid.Create C# (CSharp) Method

Create() public static method

public static Create ( ) : System.Guid
return System.Guid
        public static Guid Create(params object[] data)
        {
            // use MD5 hash to get a 16-byte hash of the string
            using (var provider = new MD5CryptoServiceProvider())
            {
                var inputBytes = Encoding.Default.GetBytes(string.Concat(data));
                var hashBytes = provider.ComputeHash(inputBytes);
                // generate a guid from the hash:
                return new Guid(hashBytes);
            }
        }
    }

Usage Example

Exemplo n.º 1
0
        /// <summary>
        /// In this mode, a host id will be generated from <paramref name="instanceName" /> and <paramref name="hostName" />.
        /// </summary>
        /// <remarks>
        /// This mode is recommended when deploying in Azure roles or <see cref="UsingInstalledFilePath" /> is not appropriate.
        /// </remarks>
        public HostInfoSettings UsingNames(string instanceName, string hostName)
        {
            Guard.AgainstNullAndEmpty(nameof(instanceName), instanceName);
            Guard.AgainstNullAndEmpty(nameof(hostName), hostName);

            config.Settings.Get <HostingComponent.Settings>().HostId = DeterministicGuid.Create(instanceName, hostName);
            return(this);
        }
All Usage Examples Of NServiceBus.DeterministicGuid::Create
DeterministicGuid