private IAsyncCollector <CreateCallOptions> CreateContext(TwilioCallAttribute attribute) { string accountSid = new[] { attribute.AccountSidSetting, _defaultAccountSid }.FirstOrDefault(f => !string.IsNullOrEmpty(f)); string authToken = new[] { attribute.AuthTokenSetting, _defaultAuthToken }.FirstOrDefault(f => !string.IsNullOrEmpty(f)); TwilioRestClient client = _twilioClientCache.GetOrAdd(new Tuple <string, string>(accountSid, authToken), t => new TwilioRestClient(t.Item1, t.Item2)); var context = new TwilioCallMessageAsyncCollector(client); return(context); }
private void ValidateBinding(TwilioCallAttribute attribute, Type type) { string accountSid = new[] { attribute.AccountSidSetting, _defaultAccountSid }.FirstOrDefault(f => !string.IsNullOrEmpty(f)); string authToken = new[] { attribute.AuthTokenSetting, _defaultAuthToken }.FirstOrDefault(f => !string.IsNullOrEmpty(f)); if (string.IsNullOrEmpty(accountSid)) { throw new ArgumentException(); } if (string.IsNullOrEmpty(authToken)) { throw new ArgumentException(); } }