1
- /*
1
+ /*
2
2
Copyright 2011 - 2025 Adrian Popescu
3
3
4
4
Licensed under the Apache License, Version 2.0 (the "License");
@@ -18,6 +18,7 @@ limitations under the License.
18
18
using System . Diagnostics ;
19
19
using System . Globalization ;
20
20
using System . Xml . Serialization ;
21
+ using Redmine . Net . Api . Internals ;
21
22
22
23
namespace Redmine . Net . Api . Types
23
24
{
@@ -26,7 +27,8 @@ namespace Redmine.Net.Api.Types
26
27
/// </summary>
27
28
[ DebuggerDisplay ( "{" + nameof ( DebuggerDisplay ) + ",nq}" ) ]
28
29
[ XmlRoot ( RedmineKeys . USER ) ]
29
- public sealed class Watcher : Identifiable < Watcher >
30
+ public sealed class Watcher : IdentifiableName
31
+ , IEquatable < Watcher >
30
32
, ICloneable < Watcher >
31
33
, IValue
32
34
{
@@ -47,16 +49,82 @@ public sealed class Watcher : Identifiable<Watcher>
47
49
{
48
50
if ( resetId )
49
51
{
50
- return new Watcher ( ) ;
52
+ return new Watcher ( )
53
+ {
54
+ Name = Name
55
+ } ;
51
56
}
52
57
return new Watcher
53
58
{
54
- Id = Id
59
+ Id = Id ,
60
+ Name = Name
55
61
} ;
56
62
}
57
63
58
64
#endregion
59
65
66
+ #region Implementation of IEquatable<IdentifiableName>
67
+ /// <summary>
68
+ ///
69
+ /// </summary>
70
+ /// <param name="other"></param>
71
+ /// <returns></returns>
72
+ public bool Equals ( Watcher other )
73
+ {
74
+ if ( other == null ) return false ;
75
+ return Id == other . Id && string . Equals ( Name , other . Name , StringComparison . Ordinal ) ;
76
+ }
77
+
78
+ /// <summary>
79
+ ///
80
+ /// </summary>
81
+ /// <param name="obj"></param>
82
+ /// <returns></returns>
83
+ public override bool Equals ( object obj )
84
+ {
85
+ if ( ReferenceEquals ( null , obj ) ) return false ;
86
+ if ( ReferenceEquals ( this , obj ) ) return true ;
87
+ if ( obj . GetType ( ) != GetType ( ) ) return false ;
88
+ return Equals ( obj as Watcher ) ;
89
+ }
90
+
91
+ /// <summary>
92
+ ///
93
+ /// </summary>
94
+ /// <returns></returns>
95
+ public override int GetHashCode ( )
96
+ {
97
+ unchecked
98
+ {
99
+ var hashCode = base . GetHashCode ( ) ;
100
+ hashCode = HashCodeHelper . GetHashCode ( Name , hashCode ) ;
101
+ return hashCode ;
102
+ }
103
+ }
104
+
105
+ /// <summary>
106
+ ///
107
+ /// </summary>
108
+ /// <param name="left"></param>
109
+ /// <param name="right"></param>
110
+ /// <returns></returns>
111
+ public static bool operator == ( Watcher left , Watcher right )
112
+ {
113
+ return Equals ( left , right ) ;
114
+ }
115
+
116
+ /// <summary>
117
+ ///
118
+ /// </summary>
119
+ /// <param name="left"></param>
120
+ /// <param name="right"></param>
121
+ /// <returns></returns>
122
+ public static bool operator != ( Watcher left , Watcher right )
123
+ {
124
+ return ! Equals ( left , right ) ;
125
+ }
126
+ #endregion
127
+
60
128
/// <summary>
61
129
///
62
130
/// </summary>
0 commit comments