private static void RegisterCommonViewModels(IMutableDependencyResolver services, IReadonlyDependencyResolver resolver)
 {
     services.RegisterLazySingleton <IFilesOperationsMediator>(() => new FilesOperationsMediator(
                                                                   resolver.GetRequiredService <IDirectoryService>()
                                                                   ));
     services.Register(() => new TerminalSettingsViewModel(
                           resolver.GetRequiredService <ITerminalService>()
                           ));
     services.Register(() => new GeneralSettingsViewModel(
                           resolver.GetRequiredService <LanguageSettingsViewModel>(),
                           resolver.GetRequiredService <ThemeSettingsViewModel>()
                           ));
     services.Register(() => new LanguageSettingsViewModel(
                           resolver.GetRequiredService <ILocalizationService>(),
                           resolver.GetRequiredService <ILanguageManager>()
                           ));
     services.Register(() => new ThemeSettingsViewModel(
                           resolver.GetRequiredService <IThemeService>(),
                           resolver.GetRequiredService <IThemeViewModelFactory>()
                           ));
     services.Register(() => new SettingsDialogViewModel(
                           resolver.GetRequiredService <GeneralSettingsViewModel>(),
                           resolver.GetRequiredService <TerminalSettingsViewModel>()
                           ));
     services.RegisterLazySingleton(() => new FilePropertiesBehavior(
                                        resolver.GetRequiredService <IDialogService>()
                                        ));
     services.RegisterLazySingleton(() => new DirectoryPropertiesBehavior(
                                        resolver.GetRequiredService <IDialogService>()
                                        ));
     services.Register(() => new AboutDialogViewModel(
                           resolver.GetRequiredService <IApplicationVersionProvider>(),
                           resolver.GetRequiredService <IResourceOpeningService>(),
                           resolver.GetRequiredService <AboutDialogConfiguration>()
                           ));
     services.Register(() => new CreateArchiveDialogViewModel(
                           resolver.GetRequiredService <IDirectoryService>(),
                           resolver.GetRequiredService <IFileService>(),
                           resolver.GetRequiredService <IArchiveTypeViewModelFactory>(),
                           resolver.GetRequiredService <ISystemDialogService>(),
                           resolver.GetRequiredService <ICreateArchiveStateService>()
                           ));
     services.Register(() => new DirectoryInformationDialogViewModel(
                           resolver.GetRequiredService <IDirectoryService>(),
                           resolver.GetRequiredService <IApplicationDispatcher>(),
                           resolver.GetRequiredService <MainNodeInfoTabViewModel>()
                           ));
     services.Register(() => new FileInformationDialogViewModel(
                           resolver.GetRequiredService <IFileService>(),
                           resolver.GetRequiredService <MainNodeInfoTabViewModel>()
                           ));
     services.Register(() => new OverwriteOptionsDialogViewModel(
                           resolver.GetRequiredService <IFileService>(),
                           resolver.GetRequiredService <IFileSystemNodeViewModelFactory>(),
                           resolver.GetRequiredService <IFileNameGenerationService>(),
                           resolver.GetRequiredService <IPathService>()
                           ));
     services.Register(() => new CreateDirectoryDialogViewModel(
                           resolver.GetRequiredService <IDirectoryService>(),
                           resolver.GetRequiredService <IFileService>(),
                           resolver.GetRequiredService <IPathService>()
                           ));
     services.Register(() => new CreateFileDialogViewModel(
                           resolver.GetRequiredService <IDirectoryService>(),
                           resolver.GetRequiredService <IFileService>(),
                           resolver.GetRequiredService <IPathService>()
                           ));
     services.Register(() => new RenameNodeDialogViewModel(
                           resolver.GetRequiredService <IDirectoryService>(),
                           resolver.GetRequiredService <IFileService>(),
                           resolver.GetRequiredService <IPathService>()
                           ));
     services.RegisterLazySingleton <IOperationsStateViewModel>(() => new OperationsStatesListViewModel(
                                                                    resolver.GetRequiredService <IOperationsStateService>(),
                                                                    resolver.GetRequiredService <IOperationStateViewModelFactory>(),
                                                                    resolver.GetRequiredService <IApplicationDispatcher>(),
                                                                    resolver.GetRequiredService <IDialogService>(),
                                                                    resolver.GetRequiredService <OperationsStatesConfiguration>()
                                                                    ));
     services.Register(() => new RemoveNodesConfirmationDialogViewModel(
                           resolver.GetRequiredService <IPathService>()
                           ));
     services.Register <IOperationsViewModel>(() => new OperationsViewModel(
                                                  resolver.GetRequiredService <IFilesOperationsMediator>(),
                                                  resolver.GetRequiredService <IOperationsService>(),
                                                  resolver.GetRequiredService <INodesSelectionService>(),
                                                  resolver.GetRequiredService <IDialogService>(),
                                                  resolver.GetRequiredService <IDirectoryService>(),
                                                  resolver.GetRequiredService <ITrashCanService>()
                                                  ));
     services.RegisterLazySingleton <IMenuViewModel>(() => new MenuViewModel(
                                                         resolver.GetRequiredService <IApplicationCloser>(),
                                                         resolver.GetRequiredService <IDialogService>()
                                                         ));
     services.Register(() => new OpenWithDialogViewModel(
                           resolver.GetRequiredService <IApplicationService>(),
                           resolver.GetRequiredService <OpenWithDialogConfiguration>()
                           ));
     services.Register <ISearchViewModel>(() => new SearchViewModel(
                                              resolver.GetRequiredService <IRegexService>(),
                                              resolver.GetRequiredService <IResourceProvider>(),
                                              resolver.GetRequiredService <IApplicationDispatcher>(),
                                              resolver.GetRequiredService <SearchViewModelConfiguration>()
                                              ));
     services.RegisterLazySingleton <IDrivesListViewModel>(() => new DrivesListViewModel(
                                                               resolver.GetRequiredService <IMountedDriveService>(),
                                                               resolver.GetRequiredService <IUnmountedDriveService>(),
                                                               resolver.GetRequiredService <IDrivesUpdateService>(),
                                                               resolver.GetRequiredService <IDriveViewModelFactory>(),
                                                               resolver.GetRequiredService <IApplicationDispatcher>()
                                                               ));
     services.RegisterLazySingleton <ITopOperationsViewModel>(() => new TopOperationsViewModel(
                                                                  resolver.GetRequiredService <ITerminalService>(),
                                                                  resolver.GetRequiredService <IDirectoryService>(),
                                                                  resolver.GetRequiredService <IFilesOperationsMediator>(),
                                                                  resolver.GetRequiredService <IDialogService>(),
                                                                  resolver.GetRequiredService <IPathService>(),
                                                                  resolver.GetRequiredService <IArchiveService>(),
                                                                  resolver.GetRequiredService <INodesSelectionService>(),
                                                                  resolver.GetRequiredService <ISystemDialogService>()
                                                                  ));
     services.RegisterLazySingleton <IOperationStateViewModelFactory>(() => new OperationStateViewModelFactory(
                                                                          resolver.GetRequiredService <IPathService>()
                                                                          ));
     services.RegisterLazySingleton(() => new MainWindowViewModel(
                                        resolver.GetRequiredService <IFilesOperationsMediator>(),
                                        resolver.GetRequiredService <IOperationsViewModel>(),
                                        CreateFilesPanelViewModel(resolver, "Left"),
                                        CreateFilesPanelViewModel(resolver, "Right"),
                                        resolver.GetRequiredService <IMenuViewModel>(),
                                        resolver.GetRequiredService <IOperationsStateViewModel>(),
                                        resolver.GetRequiredService <ITopOperationsViewModel>(),
                                        resolver.GetRequiredService <IDrivesListViewModel>(),
                                        resolver.GetRequiredService <IFavouriteDirectoriesListViewModel>()
                                        ));
 }
        private static void RegisterPlatformSpecificViewModels(IMutableDependencyResolver services, IReadonlyDependencyResolver resolver)
        {
            var platformService = resolver.GetRequiredService <IPlatformService>();
            var platform        = platformService.GetPlatform();

            if (platform is Platform.MacOs)
            {
                RegisterMacViewModels(services, resolver);
            }
        }
 public static void Register(IMutableDependencyResolver services, IReadonlyDependencyResolver resolver)
 {
     RegisterServices(services, resolver);
     RegisterViewModels(services, resolver);
 }
Exemple #4
0
        /// <summary>
        /// Initializes a ReactiveUI dependency resolver with classes that
        /// Akavache uses internally.
        /// </summary>
        /// <param name="resolver">The resolver to register Akavache based dependencies against.</param>
        /// <param name="readonlyDependencyResolver">The readonly dependency resolver.</param>
        public static void InitializeAkavache(this IMutableDependencyResolver resolver, IReadonlyDependencyResolver readonlyDependencyResolver)
        {
            var namespaces = new[]
            {
                "Akavache",
                "Akavache.Core",
                "Akavache.Mac",
                "Akavache.Deprecated",
                "Akavache.Mobile",
                "Akavache.Sqlite3",
            };

            var fdr = typeof(DependencyResolverMixin);

            if (fdr == null || fdr.AssemblyQualifiedName == null)
            {
                throw new Exception($"Cannot find valid assembly name for the {nameof(DependencyResolverMixin)} class.");
            }

            var assemblyName = new AssemblyName(
                fdr.AssemblyQualifiedName.Replace(fdr.FullName + ", ", string.Empty));

            foreach (var ns in namespaces)
            {
                var    targetType = ns + ".Registrations";
                string fullName   = targetType + ", " + assemblyName.FullName.Replace(assemblyName.Name, ns);

                var registerTypeClass = Type.GetType(fullName, false);
                if (registerTypeClass == null)
                {
                    continue;
                }

                var registerer = (IWantsToRegisterStuff)Activator.CreateInstance(registerTypeClass);
                registerer.Register(resolver, readonlyDependencyResolver);
            }
        }
    private static async Task InitializeApplicationsList(IReadonlyDependencyResolver resolver)
    {
        var applicationService = resolver.GetRequiredService <IApplicationService>();

        await applicationService.GetInstalledApplicationsAsync();
    }
Exemple #6
0
        public void Register(IMutableDependencyResolver services, IReadonlyDependencyResolver resolver)
        {
            services.Register <Serilog.ILogger>(
                () =>
            {
                var storage = resolver.GetService <IApplicationStorage>();
                return(new LoggerConfiguration()
                       .WriteTo.Console()
                       .WriteTo.File(Path.Combine(storage.LogDirectory, "application.log"))
                       .CreateLogger());
            });

            services.RegisterLazySingleton <IApplicationInfo>(
                () => new ApplicationInfo(
                    Assembly.GetExecutingAssembly()));

            services.RegisterLazySingleton <IApiClient>(
                () =>
            {
                var httpClient = new HttpClient
                {
                    BaseAddress = new Uri("https://api.rbmk.io")
                };
                return(new ApiClient(httpClient));
            });
            services.RegisterLazySingleton <IWebBrowser>(
                () => new WebBrowser());

            services.RegisterLazySingleton <IBroadcastService>(
                () => new BroadcastService());
            services.RegisterLazySingleton <IUpdateStorage>(
                () => new UpdateStorage(
                    resolver.GetService <IDatabaseContextFactory>()));
            services.RegisterLazySingleton <IUpdateService>(
                () => new UpdateService(
                    resolver.GetService <IApplicationInfo>(),
                    resolver.GetService <IApiClient>(),
                    resolver.GetService <IUpdateStorage>()));

            services.RegisterLazySingleton <IDialogProvider>(
                () => new DialogProvider(
                    typeof(MainApplication).Assembly));
            services.RegisterLazySingleton <IDialogManager>(
                () => new DialogManager(
                    resolver.GetService <IDialogProvider>()));
            services.RegisterLazySingleton <INotificationManager>(
                () => new NotificationManager());

            services.RegisterLazySingleton <IApplicationStorage>(
                () => ApplicationStorage.Instance);
            services.RegisterLazySingleton <IDatabaseContextFactory>(
                () => new DatabaseContextFactory());

            services.RegisterLazySingleton <ILicenseChecker>(
                () => new LicenseChecker());
            services.RegisterLazySingleton <ILicenseStorage>(
                () => new LicenseStorage(
                    resolver.GetService <IDatabaseContextFactory>()));
            services.RegisterLazySingleton <ILicenseService>(
                () => new LicenseService(
                    resolver.GetService <ILicenseStorage>(),
                    resolver.GetService <ILicenseChecker>()));

            services.RegisterLazySingleton <IClientAccessor>(
                () => new ClientAccessor());
            services.RegisterLazySingleton <IConnectionStorage>(
                () => new ConnectionStorage(
                    resolver.GetService <IDatabaseContextFactory>()));
            services.RegisterLazySingleton <IConnectionProvider>(
                () => new ConnectionProvider(
                    resolver.GetService <IBroadcastService>(),
                    resolver.GetService <IConnectionStorage>(),
                    resolver.GetService <IClientAccessor>()));
            services.RegisterLazySingleton <ICommandExecutor>(
                () => new CommandExecutor(
                    resolver.GetService <IClientAccessor>()));
            services.RegisterLazySingleton <ICommandParser>(
                () => new CommandParser());

            services.RegisterLazySingleton <IResultProjector>(
                () => new ResultProjector());
            services.RegisterLazySingleton <IStructProjector>(
                () => new StructProjector(
                    resolver.GetService <IClientAccessor>()));
        }
Exemple #7
0
 private static void RegisterLinuxServices(IMutableDependencyResolver services, IReadonlyDependencyResolver resolver)
 {
     services.RegisterLazySingleton <ILinuxRemovedFileMetadataBuilderFactory>(() => new LinuxRemovedFileMetadataBuilderFactory());
     services.RegisterLazySingleton <IUnmountedDriveService>(() => new LinuxUnmountedDriveService(
                                                                 resolver.GetRequiredService <IProcessService>(),
                                                                 resolver.GetRequiredService <IEnvironmentService>(),
                                                                 resolver.GetRequiredService <UnmountedDrivesConfiguration>()
                                                                 ));
     services.RegisterLazySingleton <ITrashCanService>(() => new LinuxTrashCanService(
                                                           resolver.GetRequiredService <IMountedDriveService>(),
                                                           resolver.GetRequiredService <IOperationsService>(),
                                                           resolver.GetRequiredService <IPathService>(),
                                                           resolver.GetRequiredService <IFileService>(),
                                                           resolver.GetRequiredService <IEnvironmentService>(),
                                                           resolver.GetRequiredService <IDirectoryService>(),
                                                           resolver.GetRequiredService <IDateTimeProvider>(),
                                                           resolver.GetRequiredService <ILinuxRemovedFileMetadataBuilderFactory>(),
                                                           resolver.GetRequiredService <IHomeDirectoryProvider>()
                                                           ));
     services.RegisterLazySingleton <IHomeDirectoryProvider>(() => new UnixHomeDirectoryProvider(
                                                                 resolver.GetRequiredService <IEnvironmentService>()
                                                                 ));
     services.RegisterLazySingleton <IDesktopEnvironmentService>(() => new DesktopEnvironmentService(
                                                                     resolver.GetRequiredService <IEnvironmentService>()
                                                                     ));
     services.RegisterLazySingleton <IShellCommandWrappingService>(() => new ShellCommandWrappingService());
     services.RegisterLazySingleton <IResourceOpeningService>(() => new ResourceOpeningServiceOpenWith(
                                                                  new LinuxResourceOpeningService(
                                                                      resolver.GetRequiredService <IProcessService>(),
                                                                      resolver.GetRequiredService <IShellCommandWrappingService>(),
                                                                      resolver.GetRequiredService <IDesktopEnvironmentService>()),
                                                                  resolver.GetRequiredService <IOpenWithApplicationService>(),
                                                                  resolver.GetRequiredService <IPathService>()
                                                                  ));
     services.RegisterLazySingleton <ITerminalService>(() => new LinuxTerminalService(
                                                           resolver.GetRequiredService <IProcessService>(),
                                                           resolver.GetRequiredService <IUnitOfWorkFactory>(),
                                                           resolver.GetRequiredService <IDesktopEnvironmentService>(),
                                                           resolver.GetRequiredService <IShellCommandWrappingService>()
                                                           ));
     services.RegisterLazySingleton <IMimeTypesReader>(() => new MimeTypesReader());
     services.RegisterLazySingleton <IIniReader>(() => new IniReader());
     services.RegisterLazySingleton <IApplicationService>(() => new LinuxApplicationService(
                                                              resolver.GetRequiredService <IFileService>(),
                                                              resolver.GetRequiredService <IIniReader>(),
                                                              resolver.GetRequiredService <IMimeTypesReader>(),
                                                              resolver.GetRequiredService <IPathService>()
                                                              ));
 }
Exemple #8
0
 /// <summary>
 /// Gets the navigation view.
 /// </summary>
 /// <param name="dependencyResolver">The dependency resolver.</param>
 /// <param name="contract">The contract.</param>
 /// <returns>The navigation view.</returns>
 public static NavigationView GetNavigationView(
     this IReadonlyDependencyResolver dependencyResolver,
     string contract = null) =>
 dependencyResolver.GetService <IView>(contract ?? NavigationView) as NavigationView;
 public SplatPerformance(int numberOfTests)
 {
     _numberOfTests    = numberOfTests;
     _mutableContainer = Locator.CurrentMutable;
     _container        = Locator.Current;
 }
Exemple #10
0
        private static void RegisterPlatformSpecificServices(IMutableDependencyResolver services, IReadonlyDependencyResolver resolver)
        {
            var platformService = resolver.GetRequiredService <IPlatformService>();
            var platform        = platformService.GetPlatform();

            switch (platform)
            {
            case Platform.Linux:
                RegisterLinuxServices(services, resolver);
                break;

            case Platform.MacOs:
                RegisterMacServices(services, resolver);
                break;

            case Platform.Windows:
                RegisterWindowsServices(services, resolver);
                break;

            case Platform.Unknown:
                throw new InvalidOperationException("Unsupported platform");

            default:
                throw new ArgumentOutOfRangeException(nameof(platform));
            }
        }
Exemple #11
0
 private static void RegisterTaskPool(IMutableDependencyResolver services, IReadonlyDependencyResolver resolver)
 {
     services.RegisterLazySingleton <ITaskPool>(() => new TaskPool.Implementations.TaskPool(
                                                    resolver.GetService <IEnvironmentService>()
                                                    ));
 }
Exemple #12
0
 private static void RegisterServices(IMutableDependencyResolver services, IReadonlyDependencyResolver resolver)
 {
     services.RegisterLazySingleton <IFileService>(() => new FileService(
                                                       resolver.GetService <IPathService>()
                                                       ));
     services.RegisterLazySingleton <IDriveService>(() => new DriveService());
     services.RegisterLazySingleton <ITrashCanServiceFactory>(() => new TrashCanServiceFactory(
                                                                  resolver.GetService <IPlatformService>(),
                                                                  resolver.GetService <IDriveService>(),
                                                                  resolver.GetService <IOperationsService>(),
                                                                  resolver.GetService <IEnvironmentService>(),
                                                                  resolver.GetService <IPathService>(),
                                                                  resolver.GetService <IFileService>(),
                                                                  resolver.GetService <IProcessService>(),
                                                                  resolver.GetService <IDirectoryService>()
                                                                  ));
     services.Register <IOperationsFactory>(() => new OperationsFactory(
                                                resolver.GetService <ITaskPool>(),
                                                resolver.GetService <IDirectoryService>(),
                                                resolver.GetService <IFileService>(),
                                                resolver.GetService <IPathService>()
                                                ));
     services.RegisterLazySingleton <IFileSystemWatchingService>(() => new FileSystemWatchingService(
                                                                     resolver.GetService <IFileSystemWatcherWrapperFactory>()
                                                                     ));
     services.RegisterLazySingleton <IFilesSelectionService>(() => new FilesSelectionService());
     services.RegisterLazySingleton <IOperationsService>(() => new OperationsService(
                                                             resolver.GetService <IOperationsFactory>(),
                                                             resolver.GetService <IDirectoryService>(),
                                                             resolver.GetService <IResourceOpeningService>(),
                                                             resolver.GetService <IFileService>(),
                                                             resolver.GetService <IPathService>()
                                                             ));
     services.RegisterLazySingleton <IDirectoryService>(() => new DirectoryService(
                                                            resolver.GetService <IPathService>()
                                                            ));
     services.RegisterLazySingleton <IResourceOpeningService>(() => new ResourceOpeningService(
                                                                  resolver.GetService <IProcessService>(),
                                                                  resolver.GetService <IPlatformService>()
                                                                  ));
     services.RegisterLazySingleton <IFileSystemWatcherWrapperFactory>(() => new FileSystemWatcherWrapperFactory());
     services.Register <IFileSystemWatchingService>(() => new FileSystemWatchingService(
                                                        resolver.GetService <IFileSystemWatcherWrapperFactory>()
                                                        ));
     services.RegisterLazySingleton(() => new FileOpeningBehavior(
                                        resolver.GetService <IResourceOpeningService>()
                                        ));
     services.RegisterLazySingleton(() => new DirectoryOpeningBehavior(
                                        resolver.GetService <IDirectoryService>()
                                        ));
     services.RegisterLazySingleton <IFileSizeFormatter>(() => new FileSizeFormatter());
     services.RegisterLazySingleton <IPathService>(() => new PathService());
     services.RegisterLazySingleton <IDialogService>(() => new DialogService(
                                                         resolver.GetService <IMainWindowProvider>()
                                                         ));
     services.RegisterLazySingleton <IClipboardOperationsService>(() => new ClipboardOperationsService(
                                                                      resolver.GetService <IClipboardService>(),
                                                                      resolver.GetService <IOperationsService>(),
                                                                      resolver.GetService <IEnvironmentService>()
                                                                      ));
 }
Exemple #13
0
 private static void RegisterFileSystemWatcherServices(IMutableDependencyResolver services, IReadonlyDependencyResolver resolver)
 {
     services.RegisterLazySingleton <IFileSystemWatcherFactory>(() => new FileSystemWatcherFactory(
                                                                    resolver.GetRequiredService <IPathService>(),
                                                                    resolver.GetRequiredService <FileSystemWatcherConfiguration>()
                                                                    ));
 }
 private static void RegisterMacViewModels(IMutableDependencyResolver services, IReadonlyDependencyResolver resolver)
 {
     services.RegisterLazySingleton(() => new MacDirectoryOpeningBehavior(
                                        resolver.GetRequiredService <FileOpeningBehavior>(),
                                        resolver.GetRequiredService <DirectoryOpeningBehavior>()
                                        ));
     services.RegisterLazySingleton <IFileSystemNodeViewModelFactory>(() => new FileSystemNodeViewModelFactory(
                                                                          resolver.GetRequiredService <FileOpeningBehavior>(),
                                                                          resolver.GetRequiredService <MacDirectoryOpeningBehavior>(),
                                                                          resolver.GetRequiredService <IFileSizeFormatter>(),
                                                                          resolver.GetRequiredService <IPathService>(),
                                                                          resolver.GetRequiredService <IOperationsService>(),
                                                                          resolver.GetRequiredService <IClipboardOperationsService>(),
                                                                          resolver.GetRequiredService <IFilesOperationsMediator>(),
                                                                          resolver.GetRequiredService <FilePropertiesBehavior>(),
                                                                          resolver.GetRequiredService <DirectoryPropertiesBehavior>(),
                                                                          resolver.GetRequiredService <IDialogService>(),
                                                                          resolver.GetRequiredService <ITrashCanService>(),
                                                                          resolver.GetRequiredService <IFileService>(),
                                                                          resolver.GetRequiredService <IDirectoryService>(),
                                                                          resolver.GetRequiredService <IArchiveService>(),
                                                                          resolver.GetRequiredService <ISystemDialogService>(),
                                                                          resolver.GetRequiredService <IOpenWithApplicationService>()
                                                                          ));
 }
Exemple #15
0
 private static void RegisterWindowsServices(IMutableDependencyResolver services, IReadonlyDependencyResolver resolver)
 {
     services.RegisterLazySingleton <IWindowsRemovedFileMetadataBuilderFactory>(() => new WindowsRemovedFileMetadataBuilderFactory());
     services.RegisterLazySingleton <IWindowsTrashCanNodeNameGenerator>(() => new WindowsTrashCanNodeNameGenerator());
     services.RegisterLazySingleton <IHomeDirectoryProvider>(() => new WindowsHomeDirectoryProvider(
                                                                 resolver.GetRequiredService <IEnvironmentService>()
                                                                 ));
     services.RegisterLazySingleton <IUnmountedDriveService>(() => new WindowsUnmountedDriveService());
     services.RegisterLazySingleton <ITrashCanService>(() => new WindowsTrashCanService(
                                                           resolver.GetRequiredService <IMountedDriveService>(),
                                                           resolver.GetRequiredService <IOperationsService>(),
                                                           resolver.GetRequiredService <IPathService>(),
                                                           resolver.GetRequiredService <IFileService>(),
                                                           resolver.GetRequiredService <IDateTimeProvider>(),
                                                           resolver.GetRequiredService <IProcessService>(),
                                                           resolver.GetRequiredService <IWindowsRemovedFileMetadataBuilderFactory>(),
                                                           resolver.GetRequiredService <IWindowsTrashCanNodeNameGenerator>()
                                                           ));
     services.RegisterLazySingleton <IResourceOpeningService>(() => new ResourceOpeningServiceOpenWith(
                                                                  new WindowsResourceOpeningService(
                                                                      resolver.GetRequiredService <IProcessService>()
                                                                      ),
                                                                  resolver.GetRequiredService <IOpenWithApplicationService>(),
                                                                  resolver.GetRequiredService <IPathService>()
                                                                  ));
     services.RegisterLazySingleton <ITerminalService>(() => new WindowsTerminalService(
                                                           resolver.GetRequiredService <IProcessService>(),
                                                           resolver.GetRequiredService <IUnitOfWorkFactory>()
                                                           ));
     services.RegisterLazySingleton <IApplicationService>(() => new WindowsApplicationService(
                                                              resolver.GetRequiredService <IEnvironmentService>(),
                                                              resolver.GetRequiredService <IRegexService>(),
                                                              resolver.GetRequiredService <IApplicationInfoProvider>(),
                                                              resolver.GetRequiredService <IRegistryService>()
                                                              ));
     services.RegisterLazySingleton <IApplicationInfoProvider>(() => new WindowsApplicationInfoProvider());
     services.RegisterLazySingleton <IRegistryService>(() => new WindowsRegistryService());
 }
 public static void RegisterViewModels(IMutableDependencyResolver services, IReadonlyDependencyResolver resolver)
 {
     RegisterFactories(services, resolver);
     RegisterCommonViewModels(services, resolver);
     RegisterPlatformSpecificViewModels(services, resolver);
 }
Exemple #17
0
 public static void RegisterServices(IMutableDependencyResolver services, IReadonlyDependencyResolver resolver)
 {
     RegisterCommonServices(services, resolver);
     RegisterPlatformSpecificServices(services, resolver);
 }
 private static async Task RunTasksAsync(IReadonlyDependencyResolver resolver)
 {
     await InitializeApplicationsList(resolver);
 }
Exemple #19
0
 private static void RegisterCommonServices(IMutableDependencyResolver services, IReadonlyDependencyResolver resolver)
 {
     services.RegisterLazySingleton <IArchiveProcessorFactory>(() => new ArchiveProcessorFactory(
                                                                   resolver.GetRequiredService <IFileService>(),
                                                                   resolver.GetRequiredService <IDirectoryService>(),
                                                                   resolver.GetRequiredService <IFileNameGenerationService>(),
                                                                   resolver.GetRequiredService <IPathService>()
                                                                   ));
     services.Register <ICreateArchiveStateService>(() => new CreateArchiveStateService(
                                                        resolver.GetRequiredService <IUnitOfWorkFactory>()
                                                        ));
     services.RegisterLazySingleton <IArchiveTypeMapper>(() => new ArchiveTypeMapper(
                                                             resolver.GetRequiredService <IPathService>(),
                                                             resolver.GetRequiredService <ArchiveTypeMapperConfiguration>()
                                                             ));
     services.RegisterLazySingleton <IArchiveService>(() => new ArchiveService(
                                                          resolver.GetRequiredService <IArchiveTypeMapper>(),
                                                          resolver.GetRequiredService <IPathService>(),
                                                          resolver.GetRequiredService <IOperationsService>(),
                                                          resolver.GetRequiredService <IFileNameGenerationService>()
                                                          ));
     services.RegisterLazySingleton <IFileService>(() => new FileService(
                                                       resolver.GetRequiredService <IPathService>(),
                                                       resolver.GetRequiredService <IEnvironmentFileService>(),
                                                       resolver.GetRequiredService <ILogger>()
                                                       ));
     services.RegisterLazySingleton <IDateTimeProvider>(() => new DateTimeProvider());
     services.RegisterLazySingleton <IMountedDriveService>(() => new MountedDriveService(
                                                               resolver.GetRequiredService <IEnvironmentDriveService>()
                                                               ));
     services.RegisterLazySingleton <IDrivesUpdateService>(() => new DrivesUpdateService(
                                                               resolver.GetRequiredService <IMountedDriveService>(),
                                                               resolver.GetRequiredService <IUnmountedDriveService>(),
                                                               resolver.GetRequiredService <DriveServiceConfiguration>()
                                                               ));
     services.RegisterLazySingleton <IOperationsFactory>(() => new OperationsFactory(
                                                             resolver.GetRequiredService <IDirectoryService>(),
                                                             resolver.GetRequiredService <IFileService>(),
                                                             resolver.GetRequiredService <IPathService>(),
                                                             resolver.GetRequiredService <IFileNameGenerationService>(),
                                                             resolver.GetRequiredService <ILogger>(),
                                                             resolver.GetRequiredService <IArchiveProcessorFactory>()
                                                             ));
     services.RegisterLazySingleton <INodesSelectionService>(() => new NodesSelectionService());
     services.RegisterLazySingleton <IOperationsService>(() => new OperationsService(
                                                             resolver.GetRequiredService <IOperationsFactory>(),
                                                             resolver.GetRequiredService <IDirectoryService>(),
                                                             resolver.GetRequiredService <IResourceOpeningService>(),
                                                             resolver.GetRequiredService <IFileService>(),
                                                             resolver.GetRequiredService <IPathService>(),
                                                             resolver.GetRequiredService <IOperationsStateService>()
                                                             ));
     services.RegisterLazySingleton <IDirectoryService>(() => new DirectoryService(
                                                            resolver.GetRequiredService <IPathService>(),
                                                            resolver.GetRequiredService <IEnvironmentDirectoryService>(),
                                                            resolver.GetRequiredService <IEnvironmentFileService>(),
                                                            resolver.GetRequiredService <ILogger>()
                                                            ));
     services.Register <IFileSystemWatchingService>(() => new FileSystemWatchingService(
                                                        resolver.GetRequiredService <IFileSystemWatcherFactory>()
                                                        ));
     services.RegisterLazySingleton(() => new FileOpeningBehavior(
                                        resolver.GetRequiredService <IResourceOpeningService>()
                                        ));
     services.RegisterLazySingleton(() => new DirectoryOpeningBehavior(
                                        resolver.GetRequiredService <IDirectoryService>(),
                                        resolver.GetRequiredService <IResourceOpeningService>()
                                        ));
     services.RegisterLazySingleton <ILocalizationService>(() => new LocalizationService(
                                                               resolver.GetRequiredService <IUnitOfWorkFactory>()
                                                               ));
     services.RegisterLazySingleton <IThemeService>(() => new ThemeService(
                                                        resolver.GetRequiredService <IUnitOfWorkFactory>(),
                                                        resolver.GetRequiredService <DefaultThemeConfiguration>()
                                                        ));
     services.RegisterLazySingleton <IFileSizeFormatter>(() => new FileSizeFormatter());
     services.RegisterLazySingleton <IPathService>(() => new PathService(
                                                       resolver.GetRequiredService <IEnvironmentPathService>()
                                                       ));
     services.RegisterLazySingleton <IDialogService>(() => new DialogService(
                                                         resolver.GetRequiredService <IMainWindowProvider>()
                                                         ));
     services.RegisterLazySingleton <ISystemDialogService>(() => new SystemDialogService(
                                                               resolver.GetRequiredService <IMainWindowProvider>()
                                                               ));
     services.RegisterLazySingleton <IResourceProvider>(() => new ResourceProvider());
     services.RegisterLazySingleton <ILanguageManager>(() => new LanguageManager());
     services.RegisterLazySingleton <IClipboardOperationsService>(() => new ClipboardOperationsService(
                                                                      resolver.GetRequiredService <IClipboardService>(),
                                                                      resolver.GetRequiredService <IOperationsService>(),
                                                                      resolver.GetRequiredService <IEnvironmentService>()
                                                                      ));
     services.RegisterLazySingleton <IOperationsStateService>(() => new OperationsStateService());
     services.RegisterLazySingleton <IFileNameGenerationService>(() => new FileNameGenerationService(
                                                                     resolver.GetRequiredService <IFileService>(),
                                                                     resolver.GetRequiredService <IDirectoryService>(),
                                                                     resolver.GetRequiredService <IPathService>()
                                                                     ));
     services.RegisterLazySingleton <IOpenWithApplicationService>(() => new OpenWithApplicationService(
                                                                      resolver.GetRequiredService <IUnitOfWorkFactory>()
                                                                      ));
 }
 public static void Start(IReadonlyDependencyResolver resolver) =>
 Task.Run(() => RunTasksAsync(resolver));
Exemple #21
0
        /// <inheritdoc />
        public void Register(IMutableDependencyResolver resolver, IReadonlyDependencyResolver readonlyDependencyResolver)
        {
            if (resolver is null)
            {
                throw new ArgumentNullException(nameof(resolver));
            }

            // NB: We want the most recently registered fs, since there really
            // only should be one
            var fs = Locator.Current.GetService <IFilesystemProvider>();

            if (fs is null)
            {
                throw new Exception("Failed to initialize Akavache properly. Do you have a reference to Akavache.dll?");
            }

            var localCache = new Lazy <IBlobCache>(() =>
            {
                var directory = fs.GetDefaultLocalMachineCacheDirectory();

                if (directory is null || string.IsNullOrWhiteSpace(directory))
                {
                    throw new InvalidOperationException("There is a invalid directory being returned by the file system provider.");
                }

                fs.CreateRecursive(directory).SubscribeOn(BlobCache.TaskpoolScheduler).Wait();
                return(new SqlRawPersistentBlobCache(Path.Combine(directory, "blobs.db"), BlobCache.TaskpoolScheduler));
            });

            resolver.Register(() => localCache.Value, typeof(IBlobCache), "LocalMachine");

            var userAccount = new Lazy <IBlobCache>(() =>
            {
                var directory = fs.GetDefaultRoamingCacheDirectory();

                if (directory is null || string.IsNullOrWhiteSpace(directory))
                {
                    throw new InvalidOperationException("There is a invalid directory being returned by the file system provider.");
                }

                fs.CreateRecursive(directory).SubscribeOn(BlobCache.TaskpoolScheduler).Wait();
                return(new SqlRawPersistentBlobCache(Path.Combine(directory, "userblobs.db"), BlobCache.TaskpoolScheduler));
            });

            resolver.Register(() => userAccount.Value, typeof(IBlobCache), "UserAccount");

            var secure = new Lazy <ISecureBlobCache>(() =>
            {
                var directory = fs.GetDefaultSecretCacheDirectory();

                if (directory is null || string.IsNullOrWhiteSpace(directory))
                {
                    throw new InvalidOperationException("There is a invalid directory being returned by the file system provider.");
                }

                fs.CreateRecursive(directory).SubscribeOn(BlobCache.TaskpoolScheduler).Wait();
                return(new SQLiteEncryptedBlobCache(Path.Combine(directory, "secret.db"), Locator.Current.GetService <IEncryptionProvider>(), BlobCache.TaskpoolScheduler));
            });

            resolver.Register(() => secure.Value, typeof(ISecureBlobCache));
        }
        private static async void AddGooogle(this IMutableDependencyResolver services, IReadonlyDependencyResolver resolver)
        {
            var config = Design.IsDesignMode ? new AppConfig {
                GoogleEnabled = true
            } : resolver.GetRequiredService <AppConfig>();

            if (config.GoogleEnabled)
            {
                var service = new GoogleSheetsService();

                if (!Design.IsDesignMode)
                {
                    await service.Init();
                }
                services.Register <ISheetsService>(() => service);
            }
        }
        public static void RegisterConfiguration(IMutableDependencyResolver services, IReadonlyDependencyResolver resolver)
        {
            var configuration = BuildConfiguration();

            RegisterAboutDialogConfiguration(services, configuration);
            RegisterDatabaseConfiguration(services, resolver, configuration);
            RegisterFileSystemWatcherConfiguration(services, configuration);
            RegisterImagePreviewConfiguration(services, configuration);
            RegisterTabConfiguration(services, configuration);
            RegisterTabsListConfiguration(services, configuration);
            RegisterSearchViewModelConfiguration(services, configuration);
            RegisterDriveServiceConfiguration(services, configuration);
            RegisterUnmountedDrivesConfiguration(services, configuration);
            RegisterLoggingConfiguration(services, configuration);
            RegisterArchiveTypeMapperConfiguration(services, configuration);
            RegisterArchiveTypeViewModelFactoryConfiguration(services, configuration);
            RegisterOperationsStatesConfiguration(services, configuration);
            RegisterOpenWithDialogConfiguration(services, configuration);
            RegisterUtiToExtensionsMappingConfiguration(services, configuration);
            RegisterDefaultThemeConfiguration(services, configuration);
            RegisterThemesNamesConfiguration(services, configuration);
            RegisterLanguagesConfiguration(services, configuration);
            RegisterSuggestionsConfiguration(services, configuration);
        }
 public static TService GetRequiredService <TService>(this IReadonlyDependencyResolver readonlyDependencyResolver)
 {
     return(readonlyDependencyResolver.GetService <TService>()
            ?? throw new SimpleInjector.ActivationException($"Unable to activate {typeof(TService)}."));
 }
 public static void RegisterDataAccess(IMutableDependencyResolver services, IReadonlyDependencyResolver resolver)
 {
     services.RegisterLazySingleton <IUnitOfWorkFactory>(() => new LiteDbUnitOfWorkFactory(
                                                             resolver.GetRequiredService <DatabaseConfiguration>()
                                                             ));
 }