EventId
Identifies a logging event. The primary identifier is the "Id" property, with the "Name" property providing a short description of this type of event.
using System;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices;
namespace Microsoft.Extensions.Logging
{
[System.Runtime.CompilerServices.NullableContext(2)]
[System.Runtime.CompilerServices.Nullable(0)]
public readonly struct EventId : IEquatable<EventId>
{
public int Id { get; }
public string Name { get; }
public static implicit operator EventId(int i)
{
return new EventId(i, null);
}
public static bool operator ==(EventId left, EventId right)
{
return left.Equals(right);
}
public static bool operator !=(EventId left, EventId right)
{
return !left.Equals(right);
}
public EventId(int id, string name = null)
{
Id = id;
Name = name;
}
[System.Runtime.CompilerServices.NullableContext(1)]
public override string ToString()
{
return Name ?? Id.ToString();
}
public bool Equals(EventId other)
{
return Id == other.Id;
}
public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhen(true)] object obj)
{
if (obj == null)
return false;
if (obj is EventId) {
EventId other = (EventId)obj;
return Equals(other);
}
return false;
}
public override int GetHashCode()
{
return Id;
}
}
}