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(); });
public static ICW <TProp> Call_ <T, TProp>(this ICW <T> @this, Func <T, TProp> getter) where T : class where TProp : class { using (@this) return(@this.Call(getter)); }
private void SwitchToView(IReadOnlyList <string> names) { using (var explorer = _app.Call(_ => _.ActiveExplorer())) using (var views = _calendarFolder.Call(_ => _.Views)) { explorer.Ref.CurrentFolder = _calendarFolder.Ref; views.ForEach((ICW <Outlook.View> view) => { if (names.Contains(view.Ref.Name)) { explorer.Ref.CurrentView = view.Ref; view.Ref.Apply(); } }); } }