Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/Core/src/WeakEventManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ void RemoveEventHandler(string eventName, object? handlerTarget, MemberInfo meth
}
}

struct Subscription
readonly struct Subscription : IEquatable<Subscription>
{
/// <include file="../docs/Microsoft.Maui/WeakEventManager.xml" path="//Member[@MemberName='.ctor']/Docs/*" />
public Subscription(WeakReference? subscriber, MethodInfo handler)
Expand All @@ -148,6 +148,12 @@ public Subscription(WeakReference? subscriber, MethodInfo handler)

public readonly WeakReference? Subscriber;
public readonly MethodInfo Handler;

public bool Equals(Subscription other) => Subscriber == other.Subscriber && Handler == other.Handler;

public override bool Equals(object? obj) => obj is Subscription other && Equals(other);

public override int GetHashCode() => Subscriber?.GetHashCode() ?? 0 ^ Handler.GetHashCode();
}
}
}