/// <summary>
        /// Initializes a new instance of the <see cref="SynchronizationStoryBoard"/> class.
        /// </summary>
        /// <param name="mode">Sets the property <see cref="StoryBoardBase.Mode"/>.</param>
        public SynchronizationStoryBoard(StoryBoardMode mode)
            : base(mode)
        {
            IFeedbackService feedbackService = mode.ShouldShowToasts()
                ? Ioc.GetOrCreate <IFeedbackService>()
                : new DummyFeedbackService();
            INavigationService navigationService = mode.ShouldUseGui()
                ? Ioc.GetOrCreate <INavigationService>()
                : new DummyNavigationService();

            RegisterStep(new IsCloudServiceSetStep(
                             SynchronizationStoryStepId.IsCloudServiceSet.ToInt(), this, Ioc.GetOrCreate <ISettingsService>()));
            RegisterStep(new ShowFirstTimeDialogStep(
                             SynchronizationStoryStepId.ShowFirstTimeDialog.ToInt(), this, navigationService));
            RegisterStep(new ShowCloudStorageChoiceStep(
                             SynchronizationStoryStepId.ShowCloudStorageChoice.ToInt(), this, navigationService));
            RegisterStep(new ShowCloudStorageAccountStep(
                             SynchronizationStoryStepId.ShowCloudStorageAccount.ToInt(),
                             this,
                             navigationService,
                             Ioc.GetOrCreate <INativeBrowserService>(),
                             Ioc.GetOrCreate <ICryptoRandomService>(),
                             Ioc.GetOrCreate <ICloudStorageClientFactory>()));
            RegisterStep(new HandleOAuthRedirectStep(
                             SynchronizationStoryStepId.HandleOAuthRedirect.ToInt(),
                             this,
                             Ioc.GetOrCreate <ILanguageService>(),
                             feedbackService,
                             Ioc.GetOrCreate <ICloudStorageClientFactory>()));
            RegisterStep(new ExistsCloudRepositoryStep(
                             SynchronizationStoryStepId.ExistsCloudRepository.ToInt(),
                             this,
                             Ioc.GetOrCreate <ILanguageService>(),
                             feedbackService,
                             Ioc.GetOrCreate <ISettingsService>(),
                             Ioc.GetOrCreate <ICloudStorageClientFactory>()));
            RegisterStep(new DownloadCloudRepositoryStep(
                             SynchronizationStoryStepId.DownloadCloudRepository.ToInt(),
                             this,
                             Ioc.GetOrCreate <ILanguageService>(),
                             feedbackService,
                             Ioc.GetOrCreate <ICloudStorageClientFactory>()));
            RegisterStep(new ExistsTransferCodeStep(
                             SynchronizationStoryStepId.ExistsTransferCode.ToInt(), this, Ioc.GetOrCreate <ISettingsService>()));
            RegisterStep(new ShowTransferCodeStep(
                             SynchronizationStoryStepId.ShowTransferCode.ToInt(),
                             this,
                             navigationService,
                             feedbackService));
            RegisterStep(new DecryptCloudRepositoryStep(
                             SynchronizationStoryStepId.DecryptCloudRepository.ToInt(),
                             this,
                             Ioc.GetOrCreate <ILanguageService>(),
                             feedbackService,
                             Ioc.GetOrCreate <ISettingsService>(),
                             Ioc.GetOrCreate <INoteRepositoryUpdater>()));
            RegisterStep(new IsSameRepositoryStep(
                             SynchronizationStoryStepId.IsSameRepository.ToInt(), this, Ioc.GetOrCreate <IRepositoryStorageService>()));
            RegisterStep(new ShowMergeChoiceStep(
                             SynchronizationStoryStepId.ShowMergeChoice.ToInt(),
                             this,
                             navigationService,
                             feedbackService));
            RegisterStep(new StoreMergedRepositoryAndQuitStep(
                             SynchronizationStoryStepId.StoreMergedRepositoryAndQuit.ToInt(),
                             this,
                             Ioc.GetOrCreate <ILanguageService>(),
                             feedbackService,
                             Ioc.GetOrCreate <ISettingsService>(),
                             Ioc.GetOrCreate <ICryptoRandomService>(),
                             Ioc.GetOrCreate <IRepositoryStorageService>(),
                             Ioc.GetOrCreate <ICloudStorageClientFactory>()));
            RegisterStep(new StoreLocalRepositoryToCloudAndQuitStep(
                             SynchronizationStoryStepId.StoreLocalRepositoryToCloudAndQuit.ToInt(),
                             this,
                             Ioc.GetOrCreate <ILanguageService>(),
                             feedbackService,
                             Ioc.GetOrCreate <ISettingsService>(),
                             Ioc.GetOrCreate <ICryptoRandomService>(),
                             Ioc.GetOrCreate <IRepositoryStorageService>(),
                             Ioc.GetOrCreate <ICloudStorageClientFactory>()));
            RegisterStep(new StoreCloudRepositoryToDeviceAndQuitStep(
                             SynchronizationStoryStepId.StoreCloudRepositoryToDeviceAndQuit.ToInt(),
                             this,
                             Ioc.GetOrCreate <ILanguageService>(),
                             feedbackService,
                             Ioc.GetOrCreate <IRepositoryStorageService>()));
            RegisterStep(new StopAndShowRepositoryStep(
                             SynchronizationStoryStepId.StopAndShowRepository.ToInt(),
                             this,
                             feedbackService,
                             navigationService,
                             Ioc.GetOrCreate <IStoryBoardService>()));
        }
示例#2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="StoryBoardBase"/> class.
 /// Derrived classes should register their steps in the constructor with
 /// method <see cref="RegisterStep(IStoryBoardStep)"/>.
 /// </summary>
 /// <param name="mode">Sets the property <see cref="Mode"/>.</param>
 public StoryBoardBase(StoryBoardMode mode = StoryBoardMode.GuiAndToasts)
 {
     Mode     = mode;
     _session = new Dictionary <int, object>();
     _steps   = new List <IStoryBoardStep>();
 }
示例#3
0
 /// <summary>
 /// Checks whether the story should show messages.
 /// </summary>
 /// <param name="mode">Mode to check.</param>
 /// <returns>Returns true if it should show messages, otherwise false.</returns>
 public static bool ShouldShowToasts(this StoryBoardMode mode)
 {
     return(mode != StoryBoardMode.Silent);
 }
示例#4
0
 /// <summary>
 /// Checks whether the story should run without any user interactions or messages.
 /// </summary>
 /// <param name="mode">Mode to check.</param>
 /// <returns>Returns true if it runs silently, otherwise false.</returns>
 public static bool ShouldRunSilently(this StoryBoardMode mode)
 {
     return(mode == StoryBoardMode.Silent);
 }
示例#5
0
 /// <summary>
 /// Checks whether this mode should show dialogs for user input.
 /// </summary>
 /// <param name="mode">Mode to check.</param>
 /// <returns>Returns true if if requires the gui, otherwise false.</returns>
 public static bool ShouldUseGui(this StoryBoardMode mode)
 {
     return(mode == StoryBoardMode.GuiAndToasts);
 }