private IList <SbTopic> BuildTopicList(ISbManager SbManager, string TopicName) { IList <SbTopic> result = new List <SbTopic>(); IList <TopicDescription> topics = new List <TopicDescription>(); if (TopicName != null) { topics.Add(SbManager.GetTopicByName(TopicName)); } else { topics = SbManager.GetAllTopics(); } foreach (var topic in topics) { IList <SubscriptionDescription> subscriptions = SbManager.GetAllSubscriptions(topic.Path); TopicRuntimeInfo topicRuntimeInfo = SbManager.GetTopicRuntimeInfo(topic.Path); result.Add(new SbTopic { TopicName = topic.Path, Subscriptions = subscriptions.Select(sub => sub.SubscriptionName).ToList(), ScheduledMessages = topicRuntimeInfo.MessageCountDetails.ScheduledMessageCount }); } return(result); }
private IList <SbSubscription> BuildSubscriptionList(ISbManager sbManager, string TopicName, string SubscriptionName) { IList <SbSubscription> result = new List <SbSubscription>(); IList <SubscriptionDescription> subscriptions = new List <SubscriptionDescription>(); if (SubscriptionName != null) { subscriptions.Add(sbManager.GetSubscriptionByName(TopicName, SubscriptionName)); } else { subscriptions = sbManager.GetAllSubscriptions(TopicName); } foreach (var subscription in subscriptions) { SubscriptionRuntimeInfo subscriptionRuntimeInfo = sbManager.GetSubscriptionRuntimeInfo(TopicName, subscription.SubscriptionName); result.Add(new SbSubscription { Name = subscription.SubscriptionName, Topic = subscription.TopicPath, ActiveMessages = subscriptionRuntimeInfo.MessageCountDetails.ActiveMessageCount, DeadLetteredMessages = subscriptionRuntimeInfo.MessageCountDetails.DeadLetterMessageCount }); } return(result); }