CollectDigits.cs
1 using System.Collections.Generic;
2 using System.Linq;
4 using Newtonsoft.Json;
5 
6 namespace Microsoft.Bot.Builder.Calling.ObjectModel.Contracts
7 {
12  [JsonObject(MemberSerialization.OptOut)]
13  public class CollectDigits
14  {
18  [JsonProperty(Required = Required.Default)]
19  public uint? MaxNumberOfDtmfs { get; set; }
20 
24  [JsonProperty(Required = Required.Default)]
25  public IEnumerable<char> StopTones { get; set; }
26 
27  public void Validate()
28  {
29  bool stopTonesSet = this.StopTones != null && this.StopTones.Any();
31  this.MaxNumberOfDtmfs.GetValueOrDefault() > 0 || stopTonesSet,
32  "For CollectDigits either stopTones or maxNumberOfDigits or both must be specified");
33 
34  if (this.MaxNumberOfDtmfs.HasValue)
35  {
36  Utils.AssertArgument(this.MaxNumberOfDtmfs.Value >= MinValues.NumberOfDtmfsExpected && this.MaxNumberOfDtmfs.Value <= MaxValues.NumberOfDtmfsExpected,
37  "MaxNumberOfDtmfs has to be specified in the range of {0} - {1}", MinValues.NumberOfDtmfsExpected, MaxValues.NumberOfDtmfsExpected);
38  }
39 
40  if (stopTonesSet)
41  {
42  ValidDtmfs.Validate(this.StopTones);
43  }
44  }
45  }
46 }
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 readonly uint NumberOfDtmfsExpected
Maximum number of digits expected
Definition: MaxValues.cs:37
static readonly uint NumberOfDtmfsExpected
Maximum number of digits expected
Definition: MinValues.cs:32
This is part of the "recognize" action. If the customer wants to collect digits - this needs to be sp...
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.