public void Stop() { if (_target != null) { _target.Shutdown(); _target = null; } _subscriptions.Shutdown(); _subscriptions = new BoardSubscriptionManager(); }
private void StartIntegration(IEnumerable<System.Type> types) { const string noConfigMessage = "\n\nThis Service has not been configured or the configuration has changed.\n\nUse the Configuration Utility to configure and activate Integrations.\n\n"; var configuration = LoadConfiguration(); // pick correct implementation class for specified target type if (configuration != null && configuration.Target != null && !string.IsNullOrEmpty(configuration.Target.Type)) { var targetType = configuration.Target.Type.ToLowerInvariant(); var implementations = types.Where(x => x.IsClass && !x.IsAbstract && x.IsSubclassOf(typeof(TargetBase))).ToList(); if (!implementations.Any()) { "No integrations found.".Print(); noConfigMessage.Print(); } var implementation = implementations.FirstOrDefault(x => x.Name.ToLowerInvariant() == targetType); if (implementation != null) { _target = (TargetBase) Activator.CreateInstance(implementation, _subscriptions); new Thread(_target.Process).Start(); } else { string.Format("No integration found matching [{0}]. Valid integrations are : {1}", targetType, string.Join(", ", implementations.Select(x => x.Name).ToList())).Print(); noConfigMessage.Print(); } } else { noConfigMessage.Print(); } }