Пример #1
0
        public LedgerBookController(
            [NotNull] UiContext uiContext,
            [NotNull] LedgerBookControllerFileOperations fileOperations,
            [NotNull] LedgerBookGridBuilderFactory uiBuilder,
            [NotNull] ILedgerService ledgerService,
            [NotNull] IReconciliationService reconService,
            [NotNull] NewWindowViewLoader newWindowViewLoader)
        {
            if (uiContext == null)
            {
                throw new ArgumentNullException(nameof(uiContext));
            }

            if (fileOperations == null)
            {
                throw new ArgumentNullException(nameof(fileOperations));
            }

            if (uiBuilder == null)
            {
                throw new ArgumentNullException(nameof(uiBuilder));
            }

            if (ledgerService == null)
            {
                throw new ArgumentNullException(nameof(ledgerService));
            }

            if (reconService == null)
            {
                throw new ArgumentNullException(nameof(reconService));
            }

            if (newWindowViewLoader == null)
            {
                throw new ArgumentNullException(nameof(newWindowViewLoader));
            }

            this.uiBuilder                    = uiBuilder;
            this.ledgerService                = ledgerService;
            this.reconService                 = reconService;
            this.newWindowViewLoader          = newWindowViewLoader;
            this.messageBox                   = uiContext.UserPrompts.MessageBox;
            this.questionBox                  = uiContext.UserPrompts.YesNoBox;
            this.inputBox                     = uiContext.UserPrompts.InputBox;
            FileOperations                    = fileOperations;
            FileOperations.LedgerService      = this.ledgerService;
            this.uiContext                    = uiContext;
            this.doNotUseNumberOfMonthsToShow = 2;

            MessengerInstance = uiContext.Messenger;
            MessengerInstance.Register <BudgetReadyMessage>(this, OnBudgetReadyMessageReceived);
            MessengerInstance.Register <StatementReadyMessage>(this, OnStatementReadyMessageReceived);

            this.ledgerService.Saved  += OnSaveNotificationReceieved;
            this.ledgerService.Closed += OnClosedNotificationReceived;
            this.ledgerService.NewDataSourceAvailable += OnNewDataSourceAvailableNotificationReceived;
        }