コード例 #1
0
        public void UpdateOptions(Options options, bool checkIfOnline)
        {
            _pendingOutlookItems.Clear();
            _fullSyncPending = false;

            _profileName   = options.Name;
            _profileId     = options.Id;
            _proxyOptions  = options.ProxyOptions;
            _synchronizer  = options.Inactive ? NullOutlookSynchronizer.Instance : _synchronizerFactory.CreateSynchronizer(options);
            _interval      = TimeSpan.FromMinutes(options.SynchronizationIntervalInMinutes);
            _inactive      = options.Inactive;
            _checkIfOnline = checkIfOnline;

            if (_folderChangeWatcher != null)
            {
                _folderChangeWatcher.ItemSavedOrDeleted -= FolderChangeWatcher_ItemSavedOrDeleted;
                _folderChangeWatcher.Dispose();
                _folderChangeWatcher = null;
            }

            if (!_inactive && options.EnableChangeTriggeredSynchronization)
            {
                _folderChangeWatcher =
                    _folderChangeWatcherFactory.Create(options.OutlookFolderEntryId, options.OutlookFolderStoreId);
                _folderChangeWatcher.ItemSavedOrDeleted += FolderChangeWatcher_ItemSavedOrDeleted;
            }
        }
        public async Task UpdateOptions(Options options, GeneralOptions generalOptions)
        {
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }
            if (generalOptions == null)
            {
                throw new ArgumentNullException(nameof(generalOptions));
            }

            _pendingOutlookItems.Clear();
            _fullSyncPending = false;

            _profileName  = options.Name;
            _profileId    = options.Id;
            _proxyOptions = options.ProxyOptions;
            _synchronizer = options.Inactive ? NullOutlookSynchronizer.Instance : await _synchronizerFactory.CreateSynchronizer(options, generalOptions);

            _interval      = TimeSpan.FromMinutes(options.SynchronizationIntervalInMinutes);
            _inactive      = options.Inactive;
            _checkIfOnline = generalOptions.CheckIfOnline;

            if (_folderChangeWatcher != null)
            {
                _folderChangeWatcher.ItemSavedOrDeleted -= FolderChangeWatcher_ItemSavedOrDeleted;
                _folderChangeWatcher.Dispose();
                _folderChangeWatcher = null;
            }

            if (!_inactive && options.EnableChangeTriggeredSynchronization)
            {
                _folderChangeWatcher =
                    _folderChangeWatcherFactory.Create(options.OutlookFolderEntryId, options.OutlookFolderStoreId);
                _folderChangeWatcher.ItemSavedOrDeleted += FolderChangeWatcher_ItemSavedOrDeleted;
            }
        }