1
0
mirror of https://github.com/bitwarden/mobile.git synced 2024-11-04 08:50:18 +01:00

register services on android

This commit is contained in:
Kyle Spearrin 2019-04-18 10:40:57 -04:00
parent 43948c65f1
commit b94485be75
2 changed files with 41 additions and 9 deletions

View File

@ -42,17 +42,21 @@ namespace Bit.Droid
var liteDbStorage = new LiteDbStorageService(Path.Combine(documentsPath, "bitwarden.db"));
var deviceActionService = new DeviceActionService();
var localizeService = new LocalizeService();
var messagingService = new MobileMessagingService();
var i18nService = new MobileI18nService(localizeService.GetCurrentCultureInfo());
var secureStorageService = new SecureStorageService();
var cryptoPrimitiveService = new CryptoPrimitiveService();
var mobileStorageService = new MobileStorageService(preferencesStorage, liteDbStorage);
var platformUtilsService = new MobilePlatformUtilsService(deviceActionService);
ServiceContainer.Register<IMessagingService>("messagingService", messagingService);
ServiceContainer.Register<ILocalizeService>("localizeService", localizeService);
ServiceContainer.Register<II18nService>("i18nService",
new MobileI18nService(localizeService.GetCurrentCultureInfo()));
ServiceContainer.Register<ICryptoPrimitiveService>("cryptoPrimitiveService", new CryptoPrimitiveService());
ServiceContainer.Register<IStorageService>("storageService",
new MobileStorageService(preferencesStorage, liteDbStorage));
ServiceContainer.Register<IStorageService>("secureStorageService", new SecureStorageService());
ServiceContainer.Register<II18nService>("i18nService", i18nService);
ServiceContainer.Register<ICryptoPrimitiveService>("cryptoPrimitiveService", cryptoPrimitiveService);
ServiceContainer.Register<IStorageService>("storageService", mobileStorageService);
ServiceContainer.Register<IStorageService>("secureStorageService", secureStorageService);
ServiceContainer.Register<IDeviceActionService>("deviceActionService", deviceActionService);
ServiceContainer.Register<IPlatformUtilsService>("platformUtilsService",
new MobilePlatformUtilsService(deviceActionService));
ServiceContainer.Register<IPlatformUtilsService>("platformUtilsService", platformUtilsService);
}
}
}

View File

@ -23,6 +23,8 @@ namespace Bit.Core.Utilities
var storageService = Resolve<IStorageService>("storageService");
var secureStorageService = Resolve<IStorageService>("secureStorageService");
var cryptoPrimitiveService = Resolve<ICryptoPrimitiveService>("cryptoPrimitiveService");
var i18nService = Resolve<II18nService>("i18nService");
var messagingService = Resolve<IMessagingService>("messagingService");
var stateService = new StateService();
var cryptoFunctionService = new PclCryptoFunctionService(cryptoPrimitiveService);
@ -31,14 +33,40 @@ namespace Bit.Core.Utilities
var apiService = new ApiService(tokenService, platformUtilsService, (bool expired) => Task.FromResult(0));
var appIdService = new AppIdService(storageService);
var userService = new UserService(storageService, tokenService);
var settingsService = new SettingsService(userService, storageService);
var cipherService = new CipherService(cryptoService, userService, settingsService, apiService,
storageService, i18nService);
var folderService = new FolderService(cryptoService, userService, apiService, storageService,
i18nService, cipherService);
var collectionService = new CollectionService(cryptoService, userService, storageService, i18nService);
// TODO: lock service
var syncService = new SyncService(userService, apiService, settingsService, folderService,
cipherService, cryptoService, collectionService, storageService, messagingService);
var passwordGenerationService = new PasswordGenerationService(cryptoService, storageService,
cryptoFunctionService);
var totpService = new TotpService(storageService, cryptoFunctionService);
var authService = new AuthService(cryptoService, apiService, userService, tokenService, appIdService,
i18nService, platformUtilsService, messagingService);
// TODO: export service
var auditService = new AuditService(cryptoFunctionService, apiService);
// TODO: notification and env services
Register<IStateService>("stateService", stateService);
Register<ICryptoFunctionService>("cryptoFunctionService", cryptoFunctionService);
Register<ICryptoService>("cryptoService", cryptoService);
Register<ITokenService>("tokenService", tokenService);
Register<ApiService>("apiService", apiService); // TODO: interface
Register<IApiService>("apiService", apiService);
Register<IAppIdService>("appIdService", appIdService);
Register<IUserService>("userService", userService);
Register<ISettingsService>("settingsService", settingsService);
Register<ICipherService>("cipherService", cipherService);
Register<IFolderService>("folderService", folderService);
Register<ICollectionService>("collectionService", collectionService);
Register<ISyncService>("syncService", syncService);
Register<IPasswordGenerationService>("passwordGenerationService", passwordGenerationService);
Register<ITotpService>("totpService", totpService);
Register<IAuthService>("authService", authService);
Register<IAuditService>("auditService", auditService);
}
public static void Register<T>(string serviceName, T obj)