protected override void ConfigureContainer() { base.ConfigureContainer(); Container.Register <IWpfStartupManager, WpfStartupManager>(); Container.Register <IExceptionHandler, DefaultExceptionHandler>(); Container.RegisterPlugins <BaseCommand>(AssemblySource.Instance); // TODO Container.RegisterSingleton <SixElevatedService>(); Container.RegisterSingleton(() => DomainEvilGlobal.Settings); Container.RegisterSingleton(() => DomainEvilGlobal.LocalMachineInfo); Container.RegisterSingleton <IUserSettingsStorage>( () => new UserSettingsStorage( (ex, location) => Container.GetInstance <IDialogManager>().ExceptionDialog(ex, $"An error occurred while trying to load Settings from: {location}\nIf you continue you will loose your settings, but we will at least make a backup for you."))); Container.RegisterSingleton <Func <ProtocolPreference> >( () => Container.GetInstance <UserSettings>().AppOptions.ProtocolPreference); Container .RegisterSingleton <Func <IMultiMirrorFileDownloader, ExportLifetimeContext <IFileQueueDownloader> > >( x => { var appOptions = Container.GetInstance <UserSettings>().AppOptions; var downloader = new MultiThreadedFileQueueDownloader(appOptions.GetMaxThreads, x); return(new ExportLifetimeContext <IFileQueueDownloader>(downloader, TaskExt.NullAction)); }); }
protected override void ConfigureContainer() { base.ConfigureContainer(); Container.RegisterSingleton <IConnectionManager>( () => new ConnectionManager(CommonUrls.SignalrApi)); Container.RegisterSingleton <Func <ProtocolPreference> >( () => Container.GetInstance <UserSettings>().AppOptions.ProtocolPreference); Container.RegisterSingleton <IPlayStartupManager, PlayStartupManager>(); Container.RegisterSingleAllInterfaces <IAMapper>(AssemblySource.Instance); Container.RegisterSingleton <IExceptionHandler, PlayExceptionHandler>(); Container.RegisterSingleton(() => new Lazy <IPlayShellViewModel>(Container.GetInstance <IPlayShellViewModel>)); Container.RegisterSingleton(() => DomainEvilGlobal.Settings); Container.RegisterSingleton(() => DomainEvilGlobal.LocalMachineInfo); Container .RegisterSingleton <Func <IMultiMirrorFileDownloader, ExportLifetimeContext <IFileQueueDownloader> > >( x => { var appOptions = Container.GetInstance <UserSettings>().AppOptions; var downloader = new MultiThreadedFileQueueDownloader(appOptions.GetMaxThreads, x); return(new ExportLifetimeContext <IFileQueueDownloader>(downloader, TaskExt.NullAction)); }); Container.RegisterSingleton(() => { var appOptions = Container.GetInstance <UserSettings>().AppOptions; return(new Play.Applications.Services.SelfUpdater(() => appOptions.EnableBetaUpdates, Container.GetInstance <IEventAggregator>(), Container.GetInstance <IProcessManager>(), Container.GetInstance <IFileDownloader>(), Container.GetInstance <IMediator>(), Container.GetInstance <ExportFactory <IWebClient> >(), Container.GetInstance <IRestarter>())); }); Container.RegisterSingleton <ISelfUpdater>( () => Container.GetInstance <SelfUpdater>()); Container.RegisterSingleton <Func <ISupportServers, ExportLifetimeContext <IServerList> > >( x => { var sl = new ServerList(x, Container.GetInstance <UserSettings>(), Container.GetInstance <IEventAggregator>(), Container.GetInstance <IGameServerQueryHandler>(), Container.GetInstance <IGameContext>()); return(new ExportLifetimeContext <IServerList>(sl, sl.Dispose)); }); Container.RegisterSingleton <NotificationCenterMessageHandler>(); //Container.RegisterSingleton<INotificationCenterMessageHandler, NotificationCenterMessageHandler>(); // Does not work as intended Container.RegisterSingleton <INotificationCenterMessageHandler>( () => Container.GetInstance <NotificationCenterMessageHandler>()); Container.RegisterSingleton <IUserSettingsStorage>( () => new UserSettingsStorage( (ex, location) => Container.GetInstance <IDialogManager>().ExceptionDialog(ex, $"An error occurred while trying to load Settings from: {location}\nIf you continue you will loose your settings, but we will at least make a backup for you."))); Container.RegisterDecorator <IMediator, MediatorApiContextDecorator>(Lifestyle.Singleton); }
void RegisterDownloader() { RegisterDownloaderFactories(); Container.RegisterSingleton <IZsyncLauncher, ZsyncLauncher>(); Container.RegisterSingleton <IRsyncLauncher, RsyncLauncher>(); Container.RegisterSingleton <RsyncOutputParser>(); Container.RegisterSingleton <ZsyncOutputParser>(); Container.RegisterSingleton <ICopyFile, FileCopier>(); Container.Register <IHostChecker, HostChecker>(); Container.Register <IHostCheckerWithPing, HostCheckerWithPing>(); RegisterPlugins <IDownloadProtocol>(coreAssemblies, Lifestyle.Singleton); RegisterPlugins <IUploadProtocol>(coreAssemblies, Lifestyle.Singleton); Container.RegisterSingleton <IHttpDownloadProtocol, HttpDownloadProtocol>(); Container.RegisterSingleton <IFileDownloader, FileDownloader>(); Container.RegisterSingleton <IFileUploader, FileUploader>(); Container.RegisterSingleton <IStringDownloader, StringDownloader>(); Container.RegisterSingleton <IDataDownloader, DataDownloader>(); //_container.Register<IMultiMirrorFileDownloader, MultiMirrorFileDownloader>(); //_container.Register<IMirrorSelector, ScoreMirrorSelector>(() => new ScoreMirrorSelector()); Container.RegisterSingleton <IFileDownloadHelper, FileDownloadHelper>(); Container.RegisterSingleton <IZsyncMake, ZsyncMake>(); Container.RegisterDecorator <IFileDownloader, LoggingFileDownloaderDecorator>(Lifestyle.Singleton); Container.RegisterDecorator <IFileUploader, LoggingFileUploaderDecorator>(Lifestyle.Singleton); Container.RegisterSingleton <Func <HostCheckerType> >(() => HostCheckerType.WithPing); Container.RegisterSingleton <Func <ProtocolPreference> >(() => ProtocolPreference.Any); // TODO: Get the max concurrent download setting... based on premium etc //settings.Local.MaxConcurrentDownloads Container .RegisterSingleton <Func <IMultiMirrorFileDownloader, ExportLifetimeContext <IFileQueueDownloader> > >( x => { var downloader = new MultiThreadedFileQueueDownloader(SyncEvilGlobal.Limiter, x); return(new ExportLifetimeContext <IFileQueueDownloader>(downloader, TaskExt.NullAction)); }); }