Пример #1
0
        public void Initialize(Outlook.Application app)
        => _logger.OnEntryCall(() =>
        {
            _app = app.AsCW();
            using (var session = _app.Call(_ => _.Session))
                using (var user = session.Call(_ => _.CurrentUser))
                    using (var ns = _app.Call(_ => _.GetNamespace("MAPI")))
                    {
                        _userName       = user.Ref.Name;
                        _calendarFolder = ns.Call(_ => (Outlook.Folder)_.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderCalendar));
                        _calendarItems  = _calendarFolder.Call(_ => _.Items);
                    }

            GetHandlers()
            .Select(_ =>
            {
                var timer      = new DispatcherTimer();
                timer.Interval = new TimeSpan(0, 0, _.Period);
                return(new { Timer = timer, _.Handler });
            })
            .AsNodes()
            .Select(_ =>
            {
                _.Curr.Timer.Tick += (s, e) => _logger.OnEntryCall(() =>
                {
                    _.Curr.Timer.Stop();
                    _.Curr.Handler();
                    _.Next?.Timer?.Start();
                });
                return(_.Curr.Timer);
            })
            .ToList()
            .First()
            .Start();
        });