Exemple #1
0
        public MailBoxViewModel()
        {
            // Get MailController object.
            _mailController = DummyTrivialSingleton.GetMailControllerService();

            _mailController.LoadAllExistingMailHeaders();

            // Subscribe to MailHeader stream.Add published MailHeaders to the MailHeaders list.
            _mailController.MailHeaderStream.ObserveOnDispatcher().Subscribe(content =>
            {
                if (content != null)
                {
                    MailHeaders.Add(content);
                }
            });

            // Subscribe to MailContent stream.
            _mailController.MailContentStream.ObserveOnDispatcher().Subscribe(content =>
            {
                if (SelectedMailHeader == null || SelectedMailHeader.Uid != content.Uid)
                {
                    return;
                }
                MailContent = content;
            });

            // When selection changes, send requested to the mail controller for the email content.
            this.WhenAnyValue(x => x.SelectedMailHeader).Subscribe(selection =>
            {
                if (selection != null)
                {
                    MailContent = null;
                    _mailController.EmailContentRequestByUidStream.OnNext(selection.Uid);
                }
            });
        }