TimingEventInfo.cs 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. using System;
  2. namespace Best.HTTP.Request.Timings
  3. {
  4. public enum TimingEvents
  5. {
  6. StartNext,
  7. Finish,
  8. Abort
  9. }
  10. public readonly struct TimingEventInfo
  11. {
  12. public readonly HTTPRequest SourceRequest;
  13. public readonly TimingEvents Event;
  14. public readonly string Name;
  15. public readonly DateTime Time;
  16. public TimingEventInfo(HTTPRequest parentRequest, TimingEvents timingEvent)
  17. {
  18. this.SourceRequest = parentRequest;
  19. this.Event = timingEvent;
  20. this.Name = null;
  21. this.Time = DateTime.Now;
  22. }
  23. public TimingEventInfo(HTTPRequest parentRequest, TimingEvents timingEvent, string eventName)
  24. {
  25. this.SourceRequest = parentRequest;
  26. this.Event = timingEvent;
  27. this.Name = eventName;
  28. this.Time = DateTime.Now;
  29. }
  30. public override string ToString() => $"[{Event} \"{Name}\", Time: \"{Time.ToString("hh:mm:ss.fffffff")}\", Source: {SourceRequest.Context.Hash}]";
  31. }
  32. }