-
Notifications
You must be signed in to change notification settings - Fork 3
/
DumpedObject.cs
62 lines (55 loc) · 2.61 KB
/
DumpedObject.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
using System;
namespace vm.Aspects.Diagnostics.Implementation
{
/// <summary>
/// Stores pair of type and object which has already been dumped in the current call.
/// </summary>
struct DumpedObject : IEquatable<DumpedObject>
{
public readonly object Object;
public readonly Type Type;
public DumpedObject(object obj, Type type)
{
Object = obj;
Type = type;
}
#region Identity rules implementation
#region IEquatable<DumpedObject> Members
public bool Equals(DumpedObject other) => Object.Equals(other.Object) && Type.Equals(other.Type);
#endregion
/// <summary>
/// Determines whether the specified <see cref="object" /> is equal to this instance.
/// </summary>
/// <param name="obj">The <see cref="object" /> to compare with this instance.</param>
/// <returns>
/// <c>true</c> if the specified <see cref="object" /> is equal to this instance; otherwise, <c>false</c>.
/// </returns>
public override bool Equals(object? obj) => obj is DumpedObject dobj && Equals(dobj);
/// <summary>
/// Returns a hash code for this instance.
/// </summary>
/// <returns>
/// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.
/// </returns>
public override int GetHashCode() => HashCode.Combine(Object, Type);
/// <summary>
/// Overloads the equals operator <c>==</c> to compare two values of this struct by invoking the <see cref="DumpedObject.Equals(object)"/> method.
/// </summary>
/// <param name="left">The left operand.</param>
/// <param name="right">The right operand.</param>
/// <returns>
/// <c>true</c> if the left operand is equal by value to the right operand; otherwise <c>false</c>.
/// </returns>
public static bool operator ==(DumpedObject left, DumpedObject right) => left.Equals(right);
/// <summary>
/// Overloads the not equals operator <c>!=</c> to compare two values of this struct by invoking the <see cref="DumpedObject.Equals(object)"/> method.
/// </summary>
/// <param name="left">The left operand.</param>
/// <param name="right">The right operand.</param>
/// <returns>
/// <c>true</c> if the left operand is not equal by value to the right operand; otherwise <c>false</c>.
/// </returns>
public static bool operator !=(DumpedObject left, DumpedObject right) => !(left==right);
#endregion
}
}