Пример #1
0
 /// <summary>
 /// Generate a pseudo-random pipe name using the specified process ID, hashed MAC address and process path.
 /// </summary>
 /// <param name="processId">The process ID to use for generating the pipe name.</param>
 /// <param name="values">Additional values to incorporate into the generated name.</param>
 /// <returns>A string containing the pipe name.</returns>
 public static string CreatePipeName(int processId, params string[] values)
 {
     // Reinvoking the host can cause differences between the original path, e.g.,
     // "C:\Program Files" and "c:\Program Files". This will generate different UUID values and cause
     // deadlock when the client and server are trying to connect, so always use the lower invariant of the process.
     return(Uuid.Create($"{processId};{Environment.ProcessPath.ToLowerInvariant()};{Sha256Hasher.Hash(MacAddressGetter.GetMacAddress())};{string.Join(";", values)}")
            .ToString("B"));
 }
Пример #2
0
    public override bool Execute()
    {
        try
        {
            var value = string.Join(",", Values.Select(o => o.ItemSpec).ToArray()).ToLowerInvariant();

            Guid = Uuid.Create(new Guid(NamespaceGuid), value).ToString();
        }
        catch (Exception e)
        {
            Log.LogErrorFromException(e);
        }

        return(!Log.HasLoggedErrors);
    }
Пример #3
0
 /// <summary>
 /// Generate a pseudo-random pipe name using the specified process ID, hashed MAC address and process path.
 /// </summary>
 /// <param name="processId">The process ID to use for generating the pipe name.</param>
 /// <param name="values">Additional values to incorporate into the generated name.</param>
 /// <returns>A string containing the pipe name.</returns>
 public static string CreatePipeName(int processId, params string[] values)
 {
     return(Uuid.Create($"{processId};{Environment.ProcessPath};{Sha256Hasher.Hash(MacAddressGetter.GetMacAddress())};{string.Join(";", values)}")
            .ToString("B"));
 }