Esempio n. 1
0
 public static void ForEach_ <T, TItem>(this ICW <T> @this, Action <ICW <TItem> > action)
     where T : class, IEnumerable
     where TItem : class
 {
     using (@this)
         @this.ForEach(action);
 }
Esempio n. 2
0
 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));
 }
        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();
        });
Esempio n. 4
0
 public static void ForEach <T, TItem>(this ICW <T> @this, Action <ICW <TItem> > action)
     where T : class, IEnumerable
     where TItem : class
 {
     foreach (TItem item in @this.Ref)
     {
         using (var itemCw = item.AsCW())
             action(itemCw);
     }
 }
Esempio n. 5
0
 private void Clone(
     ICW <Outlook.MAPIFolder> folder,
     Outlook.AppointmentItem source,
     string categories)
 {
     using (var item = source.CopyTo(folder.Ref, Outlook.OlAppointmentCopyOptions.olCreateAppointment).AsCW())
     {
         item.Ref.Subject    = _env.UserName;
         item.Ref.Categories = categories;
         item.Ref.Save();
     }
 }
 public FolderSource(ICW <Outlook.MAPIFolder> folder)
 {
     _folder     = folder;
     _categories = new Lazy <IReadOnlyList <(string ID, string Name)> >(() => _folder.GetCategoriesFromTable().NullAsEmpty().ToList());
 }
Esempio n. 7
0
 public static ICW <TProp> Call <T, TProp>(this ICW <T> @this, Func <T, TProp> getter)
     where T : class
     where TProp : class
 => getter(@this.Ref).AsCW();
Esempio n. 8
0
 public static IEnumerable <(string id, string name)> GetCategoriesFromStorage(this ICW <Outlook.MAPIFolder> folder)
 => _logger.OnEntryCall(() =>