public App()
        {
            InitializeComponent();

            Directory.CreateDirectory(Paths.ROOT_DIRECTORY);

            DependencyService.Register <MockDataStore>();

            // Register transient types:
            container.RegisterType <IUserService, UserService>();
            container.RegisterType <IConvoService, ConvoService>();
            container.RegisterType <ICompressionUtility, BrotliUtility>();
            container.RegisterType <ICompressionUtilityAsync, BrotliUtilityAsync>();
            container.RegisterType <IAsymmetricKeygenRSA, AsymmetricKeygenRSA>();
            container.RegisterType <ISymmetricCryptography, SymmetricCryptography>();
            container.RegisterType <IAsymmetricCryptographyRSA, AsymmetricCryptographyRSA>();
            container.RegisterType <IServerConnectionTest, ServerConnectionTest>();
            container.RegisterType <IMessageSender, MessageSender>();
            container.RegisterType <ITotpProvider, TotpProvider>();
            container.RegisterType <IKeyExchange, KeyExchange>();
            container.RegisterType <IPasswordChanger, PasswordChanger>();
            container.RegisterType <IRegistrationService, RegistrationService>();

            // Register IoC singletons:
            container.RegisterType <User>(new ContainerControlledLifetimeManager()); // This is the application's user.
            container.RegisterType <IMethodQ, MethodQ>(new ContainerControlledLifetimeManager());
            container.RegisterType <ILogger, TextLogger>(new ContainerControlledLifetimeManager());
            container.RegisterType <IAppSettings, AppSettingsJson>(new ContainerControlledLifetimeManager());
            container.RegisterType <IUserSettings, UserSettingsJson>(new ContainerControlledLifetimeManager());
            container.RegisterType <IEventAggregator, EventAggregator>(new ContainerControlledLifetimeManager());
            container.RegisterType <IViewModelFactory, ViewModelFactory>(new ContainerControlledLifetimeManager());
            container.RegisterType <IConvoPasswordProvider, ConvoPasswordProvider>(new ContainerControlledLifetimeManager());
            container.RegisterType <IMessageFetcher, MessageFetcher>(new ContainerControlledLifetimeManager());

            user                  = container.Resolve <User>();
            logger                = container.Resolve <ILogger>();
            methodQ               = container.Resolve <IMethodQ>();
            userService           = container.Resolve <IUserService>();
            appSettings           = container.Resolve <IAppSettings>();
            userSettings          = container.Resolve <IUserSettings>();
            convoService          = container.Resolve <IConvoService>();
            totpProvider          = container.Resolve <ITotpProvider>();
            eventAggregator       = container.Resolve <IEventAggregator>();
            crypto                = container.Resolve <IAsymmetricCryptographyRSA>();
            viewModelFactory      = container.Resolve <IViewModelFactory>();
            connectionTest        = container.Resolve <IServerConnectionTest>();
            convoPasswordProvider = container.Resolve <IConvoPasswordProvider>();

            // Subscribe to important IEventAggregator PubSubEvents.
            eventAggregator.GetEvent <LogoutEvent>().Subscribe(Logout);
            eventAggregator.GetEvent <ClickedRegisterButtonEvent>().Subscribe(ShowRegistrationPage);
            eventAggregator.GetEvent <ClickedConfigureServerUrlButtonEvent>().Subscribe(ShowConfigServerUrlPage);
            eventAggregator.GetEvent <UserCreationSucceededEvent>().Subscribe(OnUserCreationSuccessful);
            eventAggregator.GetEvent <UserCreationVerifiedEvent>().Subscribe(() => ShowLoginPage(false));
            eventAggregator.GetEvent <LoginSucceededEvent>().Subscribe(OnLoginSuccessful);
            eventAggregator.GetEvent <JoinedConvoEvent>().Subscribe(OnJoinedConvo);
        }
Exemplo n.º 2
0
#pragma warning disable 1591
        public RegistrationService(IAsymmetricKeygenRSA keygen, IServerConnectionTest connectionTest, ILogger logger, IUserService userService, IAppSettings appSettings, IKeyExchange keyExchange)
        {
            this.logger         = logger;
            this.keygen         = keygen;
            this.userService    = userService;
            this.appSettings    = appSettings;
            this.keyExchange    = keyExchange;
            this.connectionTest = connectionTest;

            keyGenerationTask = Task.Run(() => keygen.GenerateKeyPair(RSA_KEY_SIZE));
        }