Пример #1
0
        private void ComboBoxProviders_SelectedIndexChanged(object sender, EventArgs e)
        {
            TextBoxServer.Text    = _getServerAddressByProvider(ComboBoxProviders.SelectedIndex);
            ComboBoxPorts.Enabled = (
                ComboBoxProviders.SelectedIndex == OauthProvider.MsLiveProvider ||
                ComboBoxProviders.SelectedIndex == OauthProvider.GoogleSmtpProvider);

            switch (ComboBoxProviders.SelectedIndex)
            {
            case OauthProvider.GoogleSmtpProvider:
                _oauthWrapper = new OauthDesktopWrapper(OauthProvider.CreateGoogleSmtpProvider());
                break;

            case OauthProvider.MsLiveProvider:
                _oauthWrapper = new OauthDesktopWrapper(OauthProvider.CreateMsLiveProvider());
                break;

            case OauthProvider.MsOffice365Provider:
                _oauthWrapper = new OauthDesktopWrapper(OauthProvider.CreateMsOffice365Provider());
                break;

            case OauthProvider.GoogleGmailApiProvider:
                _oauthWrapper = new OauthDesktopWrapper(OauthProvider.CreateGmailApiProvider());
                break;

            default:
                throw new Exception("Invalid OAUTH provider!");
            }
        }
Пример #2
0
        private void ListProviders_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            switch (ListProviders.SelectedIndex)
            {
            case OauthProvider.GoogleProvider:
                TextServer.Text     = "smtp.gmail.com";
                ListPorts.IsEnabled = true;
                _oauthWrapper       = new OauthDesktopWrapper(OauthProvider.CreateGoogleProvider());
                break;

            case OauthProvider.MsLiveProvider:
                TextServer.Text     = "smtp.live.com";
                ListPorts.IsEnabled = true;
                _oauthWrapper       = new OauthDesktopWrapper(OauthProvider.CreateMsLiveProvider());
                break;

            case OauthProvider.MsOffice365Provider:
                TextServer.Text     = "outlook.office365.com";
                ListPorts.IsEnabled = false;
                _oauthWrapper       = new OauthDesktopWrapper(OauthProvider.CreateMsOffice365Provider());
                break;

            default:
                throw new Exception("Invalid OAUTH provider!");
            }
        }
Пример #3
0
        private OauthHttpWrapper _initOauthWrapper(int providerType)
        {
            var OauthWrapper = Session["OauthWrapper"] as OauthHttpWrapper;

            if (OauthWrapper != null && OauthWrapper.Provider.ProviderType == providerType)
            {
                return(OauthWrapper);
            }

            OauthProvider provider = null;

            switch (providerType)
            {
            case OauthProvider.MsLiveProvider:
                provider = OauthProvider.CreateMsLiveProvider();
                break;

            case OauthProvider.MsOffice365Provider:
                provider = OauthProvider.CreateMsOffice365Provider();
                break;

            case OauthProvider.GoogleGmailApiProvider:
                provider = OauthProvider.CreateGoogleGmailApiProvider();
                break;

            default:
                provider = OauthProvider.CreateGoogleSmtpProvider();
                break;
            }
            OauthWrapper            = new OauthHttpWrapper(provider);
            Session["OauthWrapper"] = OauthWrapper;
            return(OauthWrapper);
        }