-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathNarrowingHandler.cs
41 lines (35 loc) · 1.19 KB
/
NarrowingHandler.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
using System;
namespace ClassLibrary4
{
public class NarrowingHandler<TInput, TOutput> : Handles<TOutput>, IEquatable<NarrowingHandler<TInput, TOutput>> where TInput : Message, TOutput
where TOutput : Message
{
public bool Equals(NarrowingHandler<TInput, TOutput> other)
{
if (ReferenceEquals(null, other))
return false;
if (ReferenceEquals(this, other))
return true;
return Equals(handler, other.handler);
}
public override int GetHashCode()
{
return (handler != null
? handler.GetHashCode()
: 0);
}
private readonly Handles<TInput> handler;
public NarrowingHandler(Handles<TInput> handler)
{
this.handler = handler;
}
public void Handle(TOutput message)
{
handler.Handle((TInput)message);
}
public override bool Equals(object obj)
{
return handler.Equals(obj);
}
}
}