public static SMSProviderBase GetProvider(IMessageStorage storage, SMSProviderType type) { switch (type) { case SMSProviderType.Thread: return(new SMSProviderThread(storage)); case SMSProviderType.Task: return(new SMSProviderTask(storage)); default: throw new NotImplementedException($"Not implemented logic for {type.ToString()} in {nameof(SMSProviderType)}"); } }
public SMSProvider GetSMSProvider(SMSProviderType type, string phoneNumber) { switch (type) { case SMSProviderType.TASK: return(new SMSProviderTask(phoneNumber)); case SMSProviderType.THREAD: return(new SMSProviderThread(phoneNumber)); default: throw new NotSupportedException($"{type.ToString()} is not supported yet."); } }
public bool SubscribeToProvider(string phoneNumber, SMSProviderType providerType) { var smsProvider = SMSProviderFactory.Instance().GetSMSProvider(providerType, phoneNumber); if (!_smsProviders.Contains(smsProvider)) { _smsProviders.Add(smsProvider); smsProvider.SMSReceived += SMSHandler; smsProvider.Start(); Output.WriteLine($"Successfully subscribed to {phoneNumber}."); return(true); } else { Output.WriteLine($"Cant subscribe to {phoneNumber}, cause subscribtion has already exist."); } return(false); }