@@ -9,15 +9,15 @@ namespace Autofac;
9
9
/// <summary>
10
10
/// The details of an individual request to resolve a service.
11
11
/// </summary>
12
- public class ResolveRequest
12
+ public readonly struct ResolveRequest : IEquatable < ResolveRequest >
13
13
{
14
14
/// <summary>
15
15
/// Shared constant value defining an empty set of parameters.
16
16
/// </summary>
17
17
internal static readonly IEnumerable < Parameter > NoParameters = Enumerable . Empty < Parameter > ( ) ;
18
18
19
19
/// <summary>
20
- /// Initializes a new instance of the <see cref="ResolveRequest"/> class .
20
+ /// Initializes a new instance of the <see cref="ResolveRequest"/> struct .
21
21
/// </summary>
22
22
/// <param name="service">The service being resolved.</param>
23
23
/// <param name="serviceRegistration">The component registration for the service.</param>
@@ -56,4 +56,33 @@ public ResolveRequest(Service service, ServiceRegistration serviceRegistration,
56
56
/// Gets the component registration for the decorator target if configured.
57
57
/// </summary>
58
58
public IComponentRegistration ? DecoratorTarget { get ; }
59
+
60
+ /// <inheritdoc/>
61
+ public override bool Equals ( object ? obj ) =>
62
+ obj is ResolveRequest other && Equals ( other ) ;
63
+
64
+ /// <inheritdoc/>
65
+ public bool Equals ( ResolveRequest other ) =>
66
+ Service == other . Service && Registration == other . Registration && ResolvePipeline == other . ResolvePipeline && Parameters == other . Parameters && DecoratorTarget == other . DecoratorTarget ;
67
+
68
+ /// <summary>
69
+ /// Implements the operator ==.
70
+ /// </summary>
71
+ /// <param name="left">The left operand.</param>
72
+ /// <param name="right">The right operand.</param>
73
+ /// <returns>The result of the operator.</returns>
74
+ public static bool operator == ( ResolveRequest left , ResolveRequest right ) => Equals ( left , right ) ;
75
+
76
+ /// <summary>
77
+ /// Implements the operator !=.
78
+ /// </summary>
79
+ /// <param name="left">The left operand.</param>
80
+ /// <param name="right">The right operand.</param>
81
+ /// <returns>The result of the operator.</returns>
82
+ public static bool operator != ( ResolveRequest left , ResolveRequest right ) =>
83
+ ! ( left == right ) ;
84
+
85
+ /// <inheritdoc/>
86
+ public override int GetHashCode ( ) =>
87
+ Service . GetHashCode ( ) ^ Registration . GetHashCode ( ) ^ ResolvePipeline . GetHashCode ( ) ^ Parameters . GetHashCode ( ) ^ ( DecoratorTarget ? . GetHashCode ( ) ?? 0 ) ;
59
88
}
0 commit comments