Example #1
0
        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)}");
            }
        }
Example #2
0
        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.");
            }
        }
Example #3
0
        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);
        }