public void Start(IProject context, IEnumerable <string> variables) { if (_project != null || _container != null) { throw new InvalidOperationException("Cannot start a new online container again."); } _project = context; try { // Ensure that the container is deleted context.OnlineVariableContainerCollection.Delete(_containerName); // Create a new container _container = context.OnlineVariableContainerCollection.Create(_containerName); // Add variables and register Event ErrorHandler.ThrowOnError(_container.AddVariable(variables.ToArray())); _container.BulkChanged += Container_BulkChanged; // Activate OnlineContainer ErrorHandler.ThrowOnError(_container.ActivateBulkMode()); ErrorHandler.ThrowOnError(_container.Activate()); _logger.Info("OnlineContainer " + _containerName + " successfully started."); } catch (Exception exception) { _logger.Error(exception); } }
public void Start(IProject context, IEnumerable <string> variables) { _project = context; // Ensure that the container is deleted context.OnlineVariableContainerCollection.Delete(_containerName); // Create a new container _container = context.OnlineVariableContainerCollection.Create(_containerName); // Add variables and register Event ErrorHandler.ThrowOnError(_container.AddVariable(variables.ToArray())); _container.BulkChanged += Container_BulkChanged; // Activate OnlineContainer ErrorHandler.ThrowOnError(_container.ActivateBulkMode()); ErrorHandler.ThrowOnError(_container.Activate()); }