private Guid GetValue(LogEventInfo logEvent) { Guid guid; if (GeneratedFromLogEvent) { int hashCode = logEvent.GetHashCode(); short b = (short)((hashCode >> 16) & 0XFFFF); short c = (short)(hashCode & 0XFFFF); long zeroDateTicks = LogEventInfo.ZeroDate.Ticks; byte d = (byte)((zeroDateTicks >> 56) & 0xFF); byte e = (byte)((zeroDateTicks >> 48) & 0xFF); byte f = (byte)((zeroDateTicks >> 40) & 0xFF); byte g = (byte)((zeroDateTicks >> 32) & 0xFF); byte h = (byte)((zeroDateTicks >> 24) & 0xFF); byte i = (byte)((zeroDateTicks >> 16) & 0xFF); byte j = (byte)((zeroDateTicks >> 8) & 0xFF); byte k = (byte)(zeroDateTicks & 0XFF); guid = new Guid(logEvent.SequenceID, b, c, d, e, f, g, h, i, j, k); } else { guid = Guid.NewGuid(); } return(guid); }
/// <summary> /// Renders a newly generated GUID string and appends it to the specified <see cref="StringBuilder" />. /// </summary> /// <param name="builder">The <see cref="StringBuilder"/> to append the rendered data to.</param> /// <param name="logEvent">Logging event.</param> protected override void Append(StringBuilder builder, LogEventInfo logEvent) { if (GeneratedFromLogEvent) { int hashCode = logEvent.GetHashCode(); short b = (short)((hashCode >> 16) & 0XFFFF); short c = (short)(hashCode & 0XFFFF); long zeroDateTicks = LogEventInfo.ZeroDate.Ticks; byte d = (byte)((zeroDateTicks >> 56) & 0xFF); byte e = (byte)((zeroDateTicks >> 48) & 0xFF); byte f = (byte)((zeroDateTicks >> 40) & 0xFF); byte g = (byte)((zeroDateTicks >> 32) & 0xFF); byte h = (byte)((zeroDateTicks >> 24) & 0xFF); byte i = (byte)((zeroDateTicks >> 16) & 0xFF); byte j = (byte)((zeroDateTicks >> 8) & 0xFF); byte k = (byte)(zeroDateTicks & 0XFF); builder.Append(new Guid(logEvent.SequenceID, b, c, d, e, f, g, h, i, j, k).ToString(Format)); } else { builder.Append(Guid.NewGuid().ToString(Format)); } }
public override int GetHashCode() { return(_logEvent.GetHashCode()); }