-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathTradeEventHelpers.cs
32 lines (30 loc) · 1 KB
/
TradeEventHelpers.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
using System;
using System.Linq;
using Akka.CQRS.Events;
namespace Akka.CQRS.Subscriptions
{
/// <summary>
/// Extension methods for working with <see cref="ITradeEvent"/>
/// </summary>
public static class TradeEventHelpers
{
public static readonly TradeEventType[] AllTradeEventTypes =
Enum.GetValues(typeof(TradeEventType)).Cast<TradeEventType>().ToArray();
public static TradeEventType ToTradeEventType(this ITradeEvent @event)
{
switch (@event)
{
case Bid b:
return TradeEventType.Bid;
case Ask a:
return TradeEventType.Ask;
case Fill f:
return TradeEventType.Fill;
case Match m:
return TradeEventType.Match;
default:
throw new ArgumentOutOfRangeException($"[{@event}] is not a supported trade event type.", nameof(@event));
}
}
}
}