Пример #1
0
        private static Option <ISyncService> CreateSyncService(IComponentContext context)
        {
            var config              = context.Resolve <GitConfig>();
            var signService         = context.Resolve <ISignService>();
            var passwordStore       = context.ResolveNamed <IDirectoryInfo>("PasswordStore");
            var notificationService = context.Resolve <INotificationService>();
            var strategies          = context.Resolve <GitSyncStrategies>();

            var factory = new SyncServiceFactory(config, passwordStore.FullName, signService, strategies);

            var syncService = factory.BuildSyncService();

            switch (factory.Status)
            {
            case SyncServiceStatus.GitLibraryNotFound:
                notificationService.ShowErrorWindow("The git2 DLL could not be found. Git support will be disabled.");
                break;

            case SyncServiceStatus.GitRepositoryNotFound:
                notificationService.ShowErrorWindow($"Failed to open the password store Git repository ({factory.Exception.GetType().Name}: {factory.Exception.Message}). Git support will be disabled.");
                break;
            }

            return(Option.FromNullable(syncService));
        }