Esempio n. 1
0
        private void UpdateFeature(FeatureMetadata feature)
        {
            lock (_pendingUpdatesLock)
            {
                _pendingUpdates.Remove(feature);
            }

            _logger.LogInformation($"Updating feature '{feature.Name}'.");

            var(result, hasUpdated) = _featureCache.GetOrUpdate(feature);

            if (!hasUpdated)
            {
                _logger.LogInformation("Feature is already up to date.");
                return;
            }

            if (!result.Success)
            {
                _logger.LogInformation("Compilation failed, skipping feature update.");
                return;
            }

            _featureAppPartManager.Remove(feature);
            _featureAppPartManager.Add(result.Assembly);

            _featureTokenProvider.CancelToken(feature);
            _actionDescriptorChangeProvider.TokenSource.Cancel();

            _logger.LogInformation($"Feature '{feature.Name}' updated.");
        }
Esempio n. 2
0
        public void Update(FeatureMetadata feature)
        {
            AddOrUpdateTask(feature);

            if (!_updatePending)
            {
                StartThrottlingTimer();
            }
            else
            {
                _logger.LogInformation("Update in progress, skipping timer start.");
            }
        }
Esempio n. 3
0
        private void AddOrUpdateTask(FeatureMetadata feature)
        {
            // Ensure thread safety while updating tasks to avoid duplication
            lock (_pendingUpdatesLock)
            {
                _logger.LogDebug($"Adding a task to update feature '{feature.Name}'.");

                // Pending task for the same feature is removed and added to the end of the list
                // Tasks that are not pending started compiling, so we add another task to the end of the list to update the feature again.
                var existingItem = _pendingUpdates.SingleOrDefault(x => x.Name.Equals(feature.Name));
                if (existingItem != null)
                {
                    _pendingUpdates.Remove(existingItem);
                }

                _pendingUpdates.Add(feature);
            }
        }