public override List <T> ToList <T>(IJsonDecoder <T> decode) { var result = new List <T>(); for (int i = 0; i < elements.Length; i++) { result.Add(decode(elements[i] as JObject)); } return(result); }
public override T[] ToArray <T>(IJsonDecoder <T> decode) { var result = new T[elements.Length]; for (int i = 0; i < elements.Length; i++) { result[i] = decode(elements[i] as JObject); } return(result); }
public VoicesClient(string azureRegion, string azureSubscriptionKey, IJsonDecoder <Voice[]> voiceListDecoder, CachingStrategy cache) { if (string.IsNullOrEmpty(azureRegion)) { throw new ArgumentException("Must provide a service region", nameof(azureRegion)); } if (string.IsNullOrEmpty(azureSubscriptionKey)) { throw new ArgumentException("Must provide a subscription key", nameof(azureSubscriptionKey)); } if (voiceListDecoder is null || voiceListDecoder.InputContentType != MediaType.Application_Json) { throw new ArgumentException("Must provide a JSON deserializer for the voice list data", nameof(voiceListDecoder)); } Cache = cache ?? new CachingStrategy(); AzureRegion = azureRegion; this.azureSubscriptionKey = azureSubscriptionKey; this.voiceListDecoder = voiceListDecoder; }
public VoicesClient(string azureRegion, string azureSubscriptionKey, IJsonDecoder <Voice[]> voiceListDecoder) : this(azureRegion, azureSubscriptionKey, voiceListDecoder, null) { }
public TextToSpeechClient(string azureRegion, string azureSubscriptionKey, string azureResourceName, IJsonDecoder <Voice[]> voiceListDecoder, AudioFormat outputFormat, IAudioDecoder audioDecoder) : this(azureRegion, azureSubscriptionKey, azureResourceName, voiceListDecoder, outputFormat, audioDecoder, null) { }
public TextToSpeechClient(string azureRegion, string azureSubscriptionKey, string azureResourceName, IJsonDecoder <Voice[]> voiceListDecoder, AudioFormat outputFormat, IAudioDecoder audioDecoder, CachingStrategy cache) : base(azureRegion, azureSubscriptionKey, azureResourceName, voiceListDecoder, outputFormat, cache) { this.audioDecoder = audioDecoder ?? throw new ArgumentException("Must provide an audio decoder", nameof(audioDecoder)); CheckDecoderFormat(); }
public virtual T Decode <T>(IJsonDecoder <T> decoder) { throw new System.InvalidCastException("Decode only works on JObject instances!"); }
public virtual List <T> ToList <T>(IJsonDecoder <T> decoder) { throw new System.InvalidCastException("Cannot cast this to a list!"); }
public virtual T[] ToArray <T>(IJsonDecoder <T> decoder) { throw new System.InvalidCastException("Cannot cast this to an array!"); }
public TextToSpeechStreamClient(string azureRegion, string azureSubscriptionKey, string azureResourceName, IJsonDecoder <Voice[]> voiceListDecoder, AudioFormat outputFormat, CachingStrategy cache) : base(azureRegion, azureSubscriptionKey, voiceListDecoder, cache) { if (string.IsNullOrEmpty(azureResourceName)) { throw new ArgumentException("Must provide a resource name that is tied to the subscription", nameof(azureResourceName)); } this.azureResourceName = azureResourceName; OutputFormat = outputFormat ?? throw new ArgumentException("Must provide an audio output format", nameof(outputFormat)); }
public override T Decode <T>(IJsonDecoder <T> decoder) { return(decoder(this)); }