public void Handle <T>(DtmfTone tone, Func <DtmfTone, T> handleStart, Action <T, DtmfTone> handleEnd) { switch (currentState) { case State.NoDtmf: if (tone != DtmfTone.None) { clientData = handleStart(tone); currentState = State.Dtmf; } break; case State.Dtmf: if (tone == DtmfTone.None) { handleEnd((T)clientData, lastTone); currentState = State.NoDtmf; } else if (tone != lastTone) { handleEnd((T)clientData, lastTone); clientData = handleStart(tone); } break; default: throw new ArgumentOutOfRangeException(); } lastTone = tone; }
public static void AddCustomTone(DtmfTone dtmfTone) { DtmfTones.Add(KeyOf(dtmfTone), dtmfTone); }
private static Tuple <int, int> KeyOf(DtmfTone t) => KeyOf(t.HighTone, t.LowTone);
.Select(x => DtmfTone.From(x.start, x.stop));