/// <summary> /// Removes the link between a publisher and a topic. /// </summary> /// <param name="publisherName">Name of the publisher.</param> /// <param name="topicName">Name of the topic.</param> internal static void RemoveLinkPublisherTopic(string publisherName, string topicName) { if (Utilities.IsNullOrWhiteSpace(publisherName)) { throw new ArgumentNullException("publisherName", "Publisher name cannot be null or empty."); } if (Utilities.IsNullOrWhiteSpace(topicName)) { throw new ArgumentNullException("topicName", "Topic name cannot be null or empty."); } PublisherClient publisher = GetPublisher(publisherName); if (publisher != null) { publisher.RemoveTopicInternal(topicName); } Topic topic = GetTopic(topicName); if (topic != null) { topic.RemovePublisherInternal(publisherName); } }
/// <summary> /// Deletes the publisher. /// </summary> /// <param name="publisherName">Name of the publisher.</param> public static void DeletePublisher(string publisherName) { if (Utilities.IsNullOrWhiteSpace(publisherName)) { throw new ArgumentNullException("publisherName", "Publisher name cannot be null or empty."); } lock (Utilities.GetSyncRoot(Publishers)) { if (Publishers.ContainsKey(publisherName)) { PublisherClient publisher = Publishers[publisherName]; foreach (var topicName in publisher.Topics) { publisher.RemoveTopicInternal(topicName); Topic topic = GetTopic(topicName); if (topic != null) { topic.RemovePublisherInternal(publisherName); } } Publishers.Remove(publisherName); } } }
/// <summary> /// Deletes the topic. /// </summary> /// <param name="topicName">Name of the topic.</param> public static void DeleteTopic(string topicName) { if (Utilities.IsNullOrWhiteSpace(topicName)) { throw new ArgumentNullException("topicName", "Topic name cannot be null or empty."); } lock (Utilities.GetSyncRoot(Topics)) { if (Topics.ContainsKey(topicName)) { Topic topic = Topics[topicName]; foreach (var publisherName in topic.Publishers) { topic.RemovePublisherInternal(publisherName); PublisherClient publisher = GetPublisher(publisherName); if (publisher != null) { publisher.RemoveTopicInternal(topicName); } } foreach (var subscriptionName in topic.Subscriptions) { topic.RemovePublisherInternal(subscriptionName); SubscriptionClient subscription = GetSubscription(subscriptionName); if (subscription != null) { subscription.RemoveTopicInternal(topicName); } } Topics.Remove(topicName); } } }