Log.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. using Muchinfo.MTPClient.Data.Enums;
  2. using System;
  3. using System.Collections.Generic;
  4. namespace Muchinfo.MTPClient.Data.Model.Account
  5. {
  6. /// <summary>
  7. /// 日志实体
  8. /// </summary>
  9. public class Log
  10. {
  11. /// <summary>
  12. /// 日志记录时间
  13. /// </summary>
  14. public DateTime Time { get; set; }
  15. /// <summary>
  16. /// 日志记录时间
  17. /// </summary>
  18. public string TimeText
  19. {
  20. get
  21. {
  22. return Time.ToString("HH:mm:ss");
  23. }
  24. }
  25. /// <summary>
  26. /// 日志内容
  27. /// </summary>
  28. public string Content { get; set; }
  29. /// <summary>
  30. /// 日志类型
  31. /// </summary>
  32. public LogType LogType { get; set; }
  33. public Log()
  34. {
  35. Time = DateTime.Now;
  36. }
  37. }
  38. public class LogComparer : IEqualityComparer<Log>
  39. {
  40. /// <summary>
  41. /// Equalses the specified x.
  42. /// </summary>
  43. /// <param name="x">The x.</param>
  44. /// <param name="y">The y.</param>
  45. /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
  46. public bool Equals(Log x, Log y)
  47. {
  48. if (x == null || y == null)
  49. {
  50. return false;
  51. }
  52. return (x.LogType == y.LogType && x.Time == y.Time);
  53. }
  54. /// <summary>
  55. /// Returns a hash code for this instance.
  56. /// </summary>
  57. /// <param name="obj">The object.</param>
  58. /// <returns>A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.</returns>
  59. public int GetHashCode(Log obj)
  60. {
  61. return obj.Time.GetHashCode();
  62. }
  63. }
  64. }