Exemplo n.º 1
0
        /// <summary>
        /// Default constructor.
        /// </summary>
        public MainController(ProtocolFactory protocolFactory, BaseController controller, PeriodicProfilesUpdater profiles)
        {
            _application = this;
            _controller  = controller;
            _profiles    = profiles;

            if (!(Debugger.IsAttached || Utils.IsRunningAsUWP))
            {
                // Add the event handler for handling UI thread exceptions to the event.
                System.Windows.Forms.Application.ThreadException += ExceptionHandler;

                // Set the unhandled exception mode to force all Windows Forms errors to go through
                // our handler.
                System.Windows.Forms.Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);

                // Add the event handler for handling non-UI thread exceptions to the event.
                AppDomain.CurrentDomain.UnhandledException += UnhandledExceptionHandler;
            }

            // Initialize WindowsFormsSynchronizationContext (sets SynchronizationContext.Current)
            SynchronizationContext.SetSynchronizationContext(new WindowsFormsSynchronizationContext());

            protocolFactory.register(new FTPProtocol(), new FTPTLSProtocol(), new SFTPProtocol(), new DAVProtocol(),
                                     new DAVSSLProtocol(), new SwiftProtocol(), new S3Protocol(), new GoogleStorageProtocol(),
                                     new AzureProtocol(), new IRODSProtocol(), new SpectraProtocol(), new B2Protocol(), new DriveProtocol(),
                                     new DropboxProtocol(), new HubicProtocol(), new LocalProtocol(), new OneDriveProtocol(), new SharepointProtocol(), new SharepointSiteProtocol(),
                                     new MantaProtocol(), new SDSProtocol(), new StoregateProtocol(), new BrickProtocol(), new NextcloudProtocol(), new OwncloudProtocol(), new CteraProtocol(), new BoxProtocol());
            protocolFactory.load();

            Locator.SetLocator(new StructureMapBootstrapper.SplatDependencyResolver());
            Locator.CurrentMutable.InitializeSplat();
            Locator.CurrentMutable.InitializeReactiveUI();

            // Execute OnStartup later
            SynchronizationContext.Current.Post(OnStartup, null);
        }