Ejemplo n.º 1
0
        public TopicState GetTopicsState()
        {
            TopicState topicState = new TopicState();

            try
            {
                _rwLock.EnterReadLock();


                foreach (var topic in _topics)
                {
                    topicState.RegisteredTopicStates.Add(topic.Value.GetTopicState());
                }
            }
            finally
            {
                _rwLock.ExitReadLock();
            }

            return(topicState);
        }
Ejemplo n.º 2
0
        public void SetTopicsState(TopicState topicStates)
        {
            if (topicStates != null)
            {
                foreach (Topic.State topicState in topicStates.RegisteredTopicStates)
                {
                    try
                    {
                        _rwLock.EnterWriteLock();
                        Topic topic = null;
                        CreateTopic(topicState.Topic);

                        if (_topics.TryGetValue(topicState.Topic, out topic))
                        {
                            topic.SetTopicState(topicState);
                        }
                    }
                    finally
                    {
                        _rwLock.ExitWriteLock();
                    }
                }
            }
        }