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