コード例 #1
0
        /// <summary>
        /// Initializes a new instance of the Locator class.
        /// </summary>
        static Locator()
        {
            ServiceLocator.SetLocatorProvider(() => SimpleIoc.Default);

            ////if (ViewModelBase.IsInDesignModeStatic)
            ////{
            ////    // Create design time view services and models
            ////    SimpleIoc.Default.Register<IDataService, DesignDataService>();
            ////}
            ////else
            ////{
            ////    // Create run time view services and models
            ////    SimpleIoc.Default.Register<IDataService, DataService>();
            ////}
            if (!SimpleIoc.Default.IsRegistered <ISecurityContext>())
            {
                SimpleIoc.Default.Register <ISecurityContext, TabletSecurityContext>(true);
            }
            SimpleIoc.Default.Register <ITraceWrapper, Log4netWrapper>(true);
            SimpleIoc.Default.Register <ITraceManager, Log4netTraceManager>(true);
            SimpleIoc.Default.Register <IDialogCoordinator, DialogCoordinator>();

            SimpleIoc.Default.Register <INavigationService, NavigationService>(true);

            SimpleIoc.Default.Register <IAPIHttpClient>(() => APIHttpClient.GetExtendedInstance(SimpleIoc.Default.GetInstance <ITraceManager>(), true), true);
            SimpleIoc.Default.Register <FFMEWebcam>(true);

            SimpleIoc.Default.Register <MainViewModel>();

            SimpleIoc.Default.Register <ILanguageStorageProvider>(() => new SQLiteLanguageStorageProvider("Data Source=Resources\\Localization.sqlite;"), true);
            SimpleIoc.Default.Register <ILocalizedStrings>(() => new LocalizedStrings(SimpleIoc.Default.GetInstance <ILanguageStorageProvider>()), true);
            SimpleIoc.Default.Register <ILocalizationManager, LocalizationManager>(true);

            SimpleIoc.Default.Register <IAuthenticationService, KProcess.Ksmed.Security.Business.API.AuthenticationService>();

            SimpleIoc.Default.Register <IPublicationService, PublicationService>();
            SimpleIoc.Default.Register <IPrepareService, PrepareService>();
            SimpleIoc.Default.Register <INotificationService, NotificationService>();
            SimpleIoc.Default.Register <IApplicationUsersService, ApplicationUsersService>();

            SimpleIoc.Default.Register <IEventSignalR, EventSignalR>(true);
            SimpleIoc.Default.Register <ISignalRFactory, SignalRFactory>(true);

            SimpleIoc.Default.GetInstance <ISignalRFactory>().Initialization(ServiceLocator.Current.GetInstance <IEventSignalR>());

            SimpleIoc.Default.Register <IAPIManager, APIManager>(true);

            SimpleIoc.Default.Register <FileTransferManager>(true);
            SimpleIoc.Default.Register <DownloadManager>(true);

            PresentationTraceSources.Refresh();
            PresentationTraceSources.DataBindingSource.Switch.Level = SourceLevels.Error;
            PresentationTraceSources.DataBindingSource.Listeners.Add(new BindingErrorTraceListener(TraceManager));
        }
コード例 #2
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());
        }