Exemple #1
0
 public EntryOperations(
     ICompositionFactory compositionFactory,
     IBackendServiceClient storage,
     IEventAggregator eventAggregator,
     IStatusBusyService statusBusyService,
     Lazy<ITranslationService> translator,
     ILocalSettingsService settingsService,
     ITelemetryService telemetry)
 {
     this.compositionFactory = compositionFactory;
     this.storage = storage;
     this.eventAggregator = eventAggregator;
     this.statusBusyService = statusBusyService;
     this.translator = translator;
     this.settingsService = settingsService;
     this.telemetry = telemetry;
 }
Exemple #2
0
        public MainViewModel(
            ICompositionFactory compositionFactory,
            IBackendServiceClient storage,
            IEventAggregator eventAggregator,
            IStatusBusyService statusBusyService,
            IEntryOperations entryOperations,
            ILocalSettingsService localSettingsService,
            IStringResourceManager stringResourceManager,
            ILogSharingService logSharingService)
            : this()
        {
            Guard.NotNull(compositionFactory, nameof(compositionFactory));
            Guard.NotNull(storage, nameof(storage));
            Guard.NotNull(eventAggregator, nameof(eventAggregator));
            Guard.NotNull(statusBusyService, nameof(statusBusyService));
            Guard.NotNull(entryOperations, nameof(entryOperations));
            Guard.NotNull(localSettingsService, nameof(localSettingsService));
            Guard.NotNull(stringResourceManager, nameof(stringResourceManager));
            Guard.NotNull(logSharingService, nameof(logSharingService));

            this.storage = storage;
            this.eventAggregator = eventAggregator;
            this.statusBusyService = statusBusyService;
            this.entryOperations = entryOperations;
            this.localSettingsService = localSettingsService;
            this.stringResourceManager = stringResourceManager;
            this.logSharingService = logSharingService;

            CompositionFactory = compositionFactory;

            FullEntryListViewModel = compositionFactory.Create<FullEntryListViewModel>();
            RandomEntryListViewModel = compositionFactory.Create<RandomEntryListViewModel>();
            EntryTextEditorViewModel = compositionFactory.Create<EntryTextEditorViewModel>();

            eventAggregator.GetEvent<EntryEditingFinishedEvent>().Subscribe(OnEntryEditingFinished);
            eventAggregator.GetEvent<EntryEditingCancelledEvent>().Subscribe(OnEntryEditingCancelled);
            eventAggregator.GetEvent<EntryDeletedEvent>().Subscribe(OnEntryDeleted);
            eventAggregator.GetEvent<EntryIsLearntChangedEvent>().Subscribe(OnEntryIsLearntChanged);
            eventAggregator.GetEvent<EntryUpdatedEvent>().SubscribeWithAsync(OnEntryDefinitionChangedAsync);
            eventAggregator.GetEvent<EntryDetailsRequestedEvent>().Subscribe(OnEntryDetailsRequested);
            eventAggregator.GetEvent<EntryQuickEditRequestedEvent>().Subscribe(OnEntryQuickEditRequested);
        }
        public EntryDetailsViewModel(
            ICompositionFactory compositionFactory,
            IBackendServiceClient storage,
            IEventAggregator eventAggregator,
            IStatusBusyService statusBusyService,
            Lazy<ITranslationService> translator)
            : this(eventAggregator)
        {
            Guard.NotNull(compositionFactory, nameof(compositionFactory));
            Guard.NotNull(storage, nameof(storage));
            Guard.NotNull(eventAggregator, nameof(eventAggregator));
            Guard.NotNull(statusBusyService, nameof(statusBusyService));
            Guard.NotNull(translator, nameof(translator));

            this.storage = storage;
            this.statusBusyService = statusBusyService;
            this.translator = translator;

            EventAggregator = eventAggregator;
            CompositionFactory = compositionFactory;
        }
Exemple #4
0
        public LogSharingService([NotNull] IBackendServiceClient serviceClient)
        {
            Guard.NotNull(serviceClient, nameof(serviceClient));

            this.serviceClient = serviceClient;
        }
Exemple #5
0
 private Task<IEnumerable<Entry>> LoadEntries(IBackendServiceClient storage)
 {
     if (ShowLearnedEntries)
     {
         return storage.LoadEntries();
     }
     else
     {
         return storage.LoadEntries(x => !x.IsLearnt);
     }
 }
Exemple #6
0
        private async Task InitializeWordListAsync(IBackendServiceClient storage)
        {
            Telemetry.Client.TrackTrace("MainPage. Loading word list started.");

            var sw = new Stopwatch();

            sw.Start();

            

            LocalDbState localDbState = LocalDbState.Unknown;

            using (await RefreshLock.LockAsync())
            {
                try
                {
                    await storage.InitializeAsync();

                    var initialPullRequired = await storage.GetIsInitialPullRequiredAsync();

                    if (initialPullRequired)
                    {
                        IsInitialLoadInProgress = true;

                        try
                        {
                            localDbState = await storage.DoInitialPullIfNeededAsync();
                        }
                        finally
                        {
                            IsInitialLoadInProgress = false;
                        }
                    }

                    await LoadDataInternalAsync();
                }
                finally
                {
                    FullEntryListViewModel.IsInitializationComplete = true;
                    RandomEntryListViewModel.IsInitializationComplete = true;
                }
            }

            sw.Stop();

            Telemetry.Client.TrackTrace("MainPage. Loading word list finished. Elapsed: " + sw.Elapsed);

            using (await RefreshLock.LockAsync())
            {
                await UpdateStatistics();
            }

            if (localDbState != LocalDbState.UpToDate)
            {
                await SyncAsync();
            }
        }
Exemple #7
0
        public LiveTileManager([NotNull] IBackendServiceClient backendServiceClient)
        {
            Guard.NotNull(backendServiceClient, nameof(backendServiceClient));

            this.backendServiceClient = backendServiceClient;
        }