ValidDtmfs.cs
1 using System.Collections.Generic;
2 using System.Linq;
4 
5 namespace Microsoft.Bot.Builder.Calling.ObjectModel.Contracts
6 {
10  public static class ValidDtmfs
11  {
15  public static readonly Dictionary<char, int> ValidDtmfSet = new Dictionary<char, int>()
16  {
17  {'0', 0},
18  {'1', 1},
19  {'2', 2},
20  {'3', 3},
21  {'4', 4},
22  {'5', 5},
23  {'6', 6},
24  {'7', 7},
25  {'8', 8},
26  {'9', 9},
27  {'*', 10},
28  {'#', 11},
29  {'A', 12},
30  {'B', 13},
31  {'C', 14},
32  {'D', 15},
33  };
34 
35  public static void Validate(char digit)
36  {
37  Utils.AssertArgument(ValidDtmfSet.ContainsKey(digit), "'{0}' is not a valid dtmf", digit);
38  }
39 
40  public static void Validate(IEnumerable<char> variations)
41  {
42  Utils.AssertArgument(variations != null, "Specified digit list is null");
43  int count = variations.Count();
44  Utils.AssertArgument(count > 0, "Specified digit list is empty");
45  Utils.AssertArgument(count <= MaxValues.NumberOfStopTones, "Number of stop tones specified cannot exceed : {0}", MaxValues.NumberOfStopTones);
46  foreach (char c in variations)
47  {
48  Validate(c);
49  }
50  }
51  }
52 }
static readonly uint NumberOfStopTones
max number of stop tones allowed
Definition: MaxValues.cs:15
Root namespace for the Microsoft Bot Builder Calling SDK object model.
static void AssertArgument(bool condition, string format, params object[] args)
Argument checker
Definition: Utils.cs:17
static void Validate(IEnumerable< char > variations)
Definition: ValidDtmfs.cs:40
Root namespace for the Microsoft Bot Builder Calling SDK.
This is a helper class for validating dtmfs specified in strings
Definition: ValidDtmfs.cs:10
Namespace for utilities and helpers in the Microsoft Bot Builder Calling SDK.
Root namespace for the Microsoft Bot Builder SDK.