Esempio n. 1
0
        public IRequestRepo Create()
        {
            string TwoFaHandler(string login, bool isAutoRelogin)
            {
                Logger.Info($"Waiting 2FA code for {login}");
                var code = _settings.TwoFaHandler?.Get(login, isAutoRelogin);

                Logger.Info($"Got 2FA code for {login}");
                return(code);
            }

            IRequestRepo repo;

            switch (_settings.Protocol)
            {
            case Protocol.WebM1Bin:
                repo = new WebM1RequestRepo(_settings.Proxy, _credentials, TwoFaHandler, _settings.ListDepth);
                break;

            case Protocol.WebV2:
                repo = new WebV2RequestRepo(_settings.Proxy, _credentials, TwoFaHandler);
                break;

            default:
                throw new Exception("Unknown protocol");
            }

            if (!string.IsNullOrWhiteSpace(_settings.UserAgent))
            {
                repo.HttpSettings.UserAgent = _settings.UserAgent;
            }

            return(repo);
        }
Esempio n. 2
0
        public IRequestRepo Create()
        {
            string TwoFaHandler(string login, bool isAutoRelogin) => _settings.TwoFaHandler?.Get(login, isAutoRelogin);

            IRequestRepo repo;

            switch (_settings.Protocol)
            {
            case Protocol.WebM1Bin:
                repo = new WebM1RequestRepo(_proxy, _credentials, TwoFaHandler);
                break;

            case Protocol.WebV2:
                repo = new WebV2RequestRepo(_proxy, _credentials, TwoFaHandler);
                break;

            default:
                throw new Exception("Unknown protocol");
            }

            if (!string.IsNullOrWhiteSpace(_settings.UserAgent))
            {
                repo.HttpSettings.UserAgent = _settings.UserAgent;
            }

            return(repo);
        }