示例#1
0
 /// <summary>
 /// Adds a subsciption to the specified topic. Events received on this topic will be cast to the given type.
 /// </summary>
 /// <param name="topic">The notification topic to add</param>
 /// <param name="type">The <see cref="Type"/> to cast notifications on this topic to</param>
 public void AddSubscription(string topic, Type type)
 {
     _notificationsApi.PostNotificationsChannelSubscriptions(Channel.Id,
                                                             new List <ChannelTopic>()
     {
         new ChannelTopic(topic)
     });
     _typeMap.Add(topic.ToLowerInvariant(), type);
 }
        /// <summary>
        /// Adds a list of subsciptions to the specified topic. Events received on this topic will be cast to the given type.
        /// </summary>
        /// <param name="subscriptions">A List of Tuples where the first value is the notification topic to add and the second is the Type that should be used when deserializing the notification</param>
        public void AddSubscriptions(List <Tuple <string, Type> > subscriptions)
        {
            var topicList = subscriptions.Select(s => new ChannelTopic(s.Item1)).Where(t => t.Id.ToLowerInvariant() != "channel.metadata").ToList();

            _notificationsApi.PostNotificationsChannelSubscriptions(Channel.Id, topicList);
            subscriptions.ForEach(s => _typeMap.Add(s.Item1.ToLowerInvariant(), s.Item2));
        }