Esempio n. 1
0
        public static void Main(string[] args)
        {
            try
            {
                XmlConfigurator.Configure ();

                logger = LogManager.GetLogger (typeof(MainClass));

                Application.EnableVisualStyles ();
                Application.SetCompatibleTextRenderingDefault (false);

                ServiceContainer.Instance.Install (
                    FromAssembly.InDirectory (new AssemblyFilter (AppDomain.CurrentDomain.BaseDirectory)));

                if (string.IsNullOrWhiteSpace (Configuration.AuthenticationProvider))
                {
                    var login = new LoginWindow ();

                    var result = login.ShowDialog ();

                    if (result != DialogResult.OK)
                        return;

                    // If Remember User is checked, then set the auth provider variable
                    if (login.IsRememberUserSet)
                    {
                        Configuration.AuthenticationProvider = login.AuthenticationProvider;
                    }
                }
                else
                {
                    var auth = new Authentication ();

                    IOAuthProvider provider = null;

                    switch (Configuration.AuthenticationProvider)
                    {
                    case "google":
                        provider = new Google ();
                        ((IOfflineOAuthProvider)provider).CodeInputView = new VerificationCodeInputWindow { Provider = "Google" };
                        break;
                    case "twitter":
                        provider = new Twitter ();
                        ((IOfflineOAuthProvider)provider).CodeInputView = new VerificationCodeInputWindow { Provider = "Twitter" };
                        break;
                    case "facebook":
                        provider = new Facebook ();
                        ((IDeviceOAuthProvider)provider).View = new CodeDisplayWindow ();
                        break;
                    }

                    auth.Login (provider);
                }

                ConfigureDuringFirstRun ();
                InitializeAndStartApp ();
                ShutdownApp ();
            }
            catch (Exception ex)
            {
                HandleException (ex);
            }
            finally
            {
                Configuration.Save ();
            }
        }
        void OnGoogleClick(object sender, EventArgs e)
        {
            var google = new Google {
                CodeInputView = new VerificationCodeInputWindow { Provider = "Google" }
            };

            PerformLogin (google, "google");
        }