Exemple #1
0
        /// <summary>
        /// Charge les services dans le service bus de l'application.
        /// </summary>
        private void LoadServices()
        {
            // Services UI
            var s = new ChildWindowService();

            ServiceBus.Register <IChildWindowService>(s);
            ServiceBus.Register <IViewHandleService>(s);
            ServiceBus.Register <ISpinnerService>(new SpinnerService());
            ServiceBus.Register <IEmailService>(new EmailService());
            ServiceBus.Register <IFreshdeskService>(new FreshdeskService());
            ServiceBus.Register <ITimeTicksFormatService>(new TimeTicksFormatService());
            ServiceBus.Register <IVideoColorService>(new VideoColorService(ServiceBus.Get <IVideoColorPersistanceService>()));

            var extManager = new ExtensionsManager();

            ServiceBus.Register <IExtensionsService>(extManager);
            ServiceBus.Register <IExtensionsManager>(extManager);

            var sharedDatabaseService = new Services.SharedDatabasePresentationService();

            ServiceBus.Register <ISharedDatabasePresentationService>(sharedDatabaseService);
            IoC.RegisterInstance <ISharedDatabaseSettingsService>(sharedDatabaseService);
            IoC.RegisterType <IReferentialsUseService, ReferentialsUseService>(true);

            IAuthenticationMode authMode = SecurityContext.GetAuthenticationMode();

            // Services Métier
            if (authMode?.Name == KSmedAuthenticationMode.StaticName)
            {
                ServiceBus.RegisterType <Business.INotificationService, KL2.Business.Impl.Desktop.NotificationService>();
                ServiceBus.RegisterType <IPrepareService, KL2.Business.Impl.Desktop.PrepareService>();
                ServiceBus.RegisterType <IAnalyzeService, KL2.Business.Impl.Desktop.AnalyzeService>();
                ServiceBus.RegisterType <IValidateService, KL2.Business.Impl.Desktop.ValidateService>();
                ServiceBus.RegisterType <IAppResourceService, KL2.Business.Impl.Desktop.AppResourceService>();
                ServiceBus.RegisterType <IAuthenticationService, Security.Business.Desktop.AuthenticationService>();
                ServiceBus.RegisterType <IDataBaseService, KL2.Business.Impl.Desktop.DataBaseService>();
                ServiceBus.RegisterType <IApplicationUsersService, KL2.Business.Impl.Desktop.ApplicationUsersService>();
                ServiceBus.RegisterType <IReferentialsService, KL2.Business.Impl.Desktop.ReferentialsService>();
                ServiceBus.RegisterType <IImportExportService, KL2.Business.Impl.Desktop.ImportExportService>();
                ServiceBus.RegisterType <ISharedDatabaseService, KL2.Business.Impl.Desktop.SharedDatabaseService>();
                ServiceBus.RegisterType <ISystemInformationService, KL2.Business.Impl.Desktop.SystemInformationService>();
                ServiceBus.RegisterType <IUISettingsService, KL2.Business.Impl.Desktop.UISettingsService>();
                ServiceBus.RegisterType <IPublicationService, KL2.Business.Impl.Desktop.PublicationService>();
            }
            else if (authMode?.Name == APIAuthenticationMode.StaticName)
            {
                // A remplacer au fur et à mesure de la migration vers l'API
                ServiceBus.RegisterType <Business.INotificationService, KL2.Business.Impl.API.NotificationService>();
                ServiceBus.RegisterType <IPrepareService, KL2.Business.Impl.API.PrepareService>();
                ServiceBus.RegisterType <IAnalyzeService, KL2.Business.Impl.API.AnalyzeService>();
                ServiceBus.RegisterType <IValidateService, KL2.Business.Impl.API.ValidateService>();
                ServiceBus.RegisterType <IAppResourceService, KL2.Business.Impl.API.AppResourceService>();
                ServiceBus.RegisterType <IAuthenticationService, Security.Business.API.AuthenticationService>();
                ServiceBus.RegisterType <IDataBaseService, KL2.Business.Impl.API.DataBaseService>();
                ServiceBus.RegisterType <IApplicationUsersService, KL2.Business.Impl.Desktop.ApplicationUsersService>();
                ServiceBus.RegisterType <IReferentialsService, KL2.Business.Impl.API.ReferentialsService>();
                ServiceBus.RegisterType <IImportExportService, KL2.Business.Impl.Desktop.ImportExportService>();
                ServiceBus.RegisterType <ISharedDatabaseService, KL2.Business.Impl.Desktop.SharedDatabaseService>();
                ServiceBus.RegisterType <ISystemInformationService, KL2.Business.Impl.Desktop.SystemInformationService>();
                ServiceBus.RegisterType <IUISettingsService, KL2.Business.Impl.API.UISettingsService>();
                ServiceBus.RegisterType <IPublicationService, KL2.Business.Impl.API.PublicationService>();
            }

            // Compatibility between Web API and WPF applications
            // HierarchicalLifetimeManager scope is new instance per request
            var authenticationMode = Container.GetExports <IAuthenticationMode>().Select(l => l.Value).ToArray();

            IoC.RegisterInstance <IEnumerable <IAuthenticationMode> >(authenticationMode);
            IoC.RegisterType <ISecurityContext, DesktopSecurityContext>(true);
            IoC.RegisterInstance <ILanguageStorageProvider>(new SQLiteLanguageStorageProvider("Data Source=Resources\\Localization.sqlite;"));
            IoC.RegisterInstance <ILocalizedStrings>(new LocalizedStrings(IoC.Resolve <ILanguageStorageProvider>()));
            IoC.RegisterType <ILocalizationManager, KL2.Languages.LocalizationManager>(true);
            IoC.RegisterType <IScenarioCloneManager, MigratedScenarioCloneManager>();
            IoC.RegisterType <ISharedScenarioActionsOperations, MigratedSharedScenarioActionsOperations>();

            // Logging
            IoC.RegisterType <ITraceManager, Log4netTraceManager>(true);
            //IoC.RegisterType<ITraceWrapper, Log4netTraceWrapper>(true);
            PresentationTraceSources.Refresh();
            PresentationTraceSources.DataBindingSource.Switch.Level = SourceLevels.Error;
            PresentationTraceSources.DataBindingSource.Listeners.Add(new BindingErrorTraceListener(IoC.Resolve <ITraceManager>()));

            // API Client
            IoC.RegisterInstance <IAPIHttpClient>(APIHttpClient.GetExtendedInstance(IoC.Resolve <ITraceManager>(), true));
            // FileTransferManager
            IoC.RegisterInstance(new FileTransferManager());
        }