ArchiveProperty.cs 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. #if UNMANAGED
  2. namespace SevenZip
  3. {
  4. /// <summary>
  5. /// Archive property struct.
  6. /// </summary>
  7. public struct ArchiveProperty
  8. {
  9. /// <summary>
  10. /// Gets the name of the archive property.
  11. /// </summary>
  12. public string Name { get; internal set; }
  13. /// <summary>
  14. /// Gets the value of the archive property.
  15. /// </summary>
  16. public object Value { get; internal set; }
  17. /// <summary>
  18. /// Determines whether the specified System.Object is equal to the current ArchiveProperty.
  19. /// </summary>
  20. /// <param name="obj">The System.Object to compare with the current ArchiveProperty.</param>
  21. /// <returns>true if the specified System.Object is equal to the current ArchiveProperty; otherwise, false.</returns>
  22. public override bool Equals(object obj)
  23. {
  24. return (obj is ArchiveProperty property) && Equals(property);
  25. }
  26. /// <summary>
  27. /// Determines whether the specified ArchiveProperty is equal to the current ArchiveProperty.
  28. /// </summary>
  29. /// <param name="afi">The ArchiveProperty to compare with the current ArchiveProperty.</param>
  30. /// <returns>true if the specified ArchiveProperty is equal to the current ArchiveProperty; otherwise, false.</returns>
  31. public bool Equals(ArchiveProperty afi)
  32. {
  33. return afi.Name == Name && afi.Value == Value;
  34. }
  35. /// <summary>
  36. /// Serves as a hash function for a particular type.
  37. /// </summary>
  38. /// <returns> A hash code for the current ArchiveProperty.</returns>
  39. public override int GetHashCode()
  40. {
  41. return Name.GetHashCode() ^ Value.GetHashCode();
  42. }
  43. /// <summary>
  44. /// Returns a System.String that represents the current ArchiveProperty.
  45. /// </summary>
  46. /// <returns>A System.String that represents the current ArchiveProperty.</returns>
  47. public override string ToString()
  48. {
  49. return Name + " = " + Value;
  50. }
  51. /// <summary>
  52. /// Determines whether the specified ArchiveProperty instances are considered equal.
  53. /// </summary>
  54. /// <param name="afi1">The first ArchiveProperty to compare.</param>
  55. /// <param name="afi2">The second ArchiveProperty to compare.</param>
  56. /// <returns>true if the specified ArchiveProperty instances are considered equal; otherwise, false.</returns>
  57. public static bool operator ==(ArchiveProperty afi1, ArchiveProperty afi2)
  58. {
  59. return afi1.Equals(afi2);
  60. }
  61. /// <summary>
  62. /// Determines whether the specified ArchiveProperty instances are not considered equal.
  63. /// </summary>
  64. /// <param name="afi1">The first ArchiveProperty to compare.</param>
  65. /// <param name="afi2">The second ArchiveProperty to compare.</param>
  66. /// <returns>true if the specified ArchiveProperty instances are not considered equal; otherwise, false.</returns>
  67. public static bool operator !=(ArchiveProperty afi1, ArchiveProperty afi2)
  68. {
  69. return !afi1.Equals(afi2);
  70. }
  71. }
  72. }
  73. #endif