1
0

Unit.cs 3.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. // Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
  2. namespace System.Reactive
  3. {
  4. /// <summary>
  5. /// Represents a type with a single value. This type is often used to denote the successful completion of a void-returning method (C#) or a Sub procedure (Visual Basic).
  6. /// </summary>
  7. #if !NO_SERIALIZABLE
  8. [Serializable]
  9. #endif
  10. public struct Unit : IEquatable<Unit>
  11. {
  12. /// <summary>
  13. /// Determines whether the specified Unit values is equal to the current Unit. Because Unit has a single value, this always returns true.
  14. /// </summary>
  15. /// <param name="other">An object to compare to the current Unit value.</param>
  16. /// <returns>Because Unit has a single value, this always returns true.</returns>
  17. public bool Equals(Unit other)
  18. {
  19. return true;
  20. }
  21. /// <summary>
  22. /// Determines whether the specified System.Object is equal to the current Unit.
  23. /// </summary>
  24. /// <param name="obj">The System.Object to compare with the current Unit.</param>
  25. /// <returns>true if the specified System.Object is a Unit value; otherwise, false.</returns>
  26. public override bool Equals(object obj)
  27. {
  28. return obj is Unit;
  29. }
  30. /// <summary>
  31. /// Returns the hash code for the current Unit value.
  32. /// </summary>
  33. /// <returns>A hash code for the current Unit value.</returns>
  34. public override int GetHashCode()
  35. {
  36. return 0;
  37. }
  38. /// <summary>
  39. /// Returns a string representation of the current Unit value.
  40. /// </summary>
  41. /// <returns>String representation of the current Unit value.</returns>
  42. public override string ToString()
  43. {
  44. return "()";
  45. }
  46. /// <summary>
  47. /// Determines whether the two specified Unit values are equal. Because Unit has a single value, this always returns true.
  48. /// </summary>
  49. /// <param name="first">The first Unit value to compare.</param>
  50. /// <param name="second">The second Unit value to compare.</param>
  51. /// <returns>Because Unit has a single value, this always returns true.</returns>
  52. [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "first", Justification = "Parameter required for operator overloading."), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "second", Justification = "Parameter required for operator overloading.")]
  53. public static bool operator ==(Unit first, Unit second)
  54. {
  55. return true;
  56. }
  57. /// <summary>
  58. /// Determines whether the two specified Unit values are not equal. Because Unit has a single value, this always returns false.
  59. /// </summary>
  60. /// <param name="first">The first Unit value to compare.</param>
  61. /// <param name="second">The second Unit value to compare.</param>
  62. /// <returns>Because Unit has a single value, this always returns false.</returns>
  63. [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "first", Justification = "Parameter required for operator overloading."), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "second", Justification = "Parameter required for operator overloading.")]
  64. public static bool operator !=(Unit first, Unit second)
  65. {
  66. return false;
  67. }
  68. static readonly Unit _default = new Unit();
  69. /// <summary>
  70. /// Gets the single unit value.
  71. /// </summary>
  72. public static Unit Default { get { return _default; } }
  73. }
  74. }