public ObjectMessageRouter RegisterHandler(Type messageType, ObjectMessageHandler handler)
        {
            var messageTypeId = _messageTypeIds[messageType];
            IList <ObjectMessageHandler> existingHandlers;

            if (!_registeredHandlers.TryGetValue(messageTypeId, out existingHandlers))
            {
                existingHandlers = new List <ObjectMessageHandler>();
                _registeredHandlers[messageTypeId] = existingHandlers;
            }
            existingHandlers.Add(handler);
            return(this);
        }
        public ObjectMessageRouter RegisterHandler(Type messageType, ObjectMessageHandler handler)
        {
            if (!_messageTypeIds.ContainsKey(messageType))
            {
                throw new Exception("Message type " + messageType + " is not registered, did you forget to import the message from the assembly?");
            }
            var messageTypeId = _messageTypeIds[messageType];
            IList <ObjectMessageHandler> existingHandlers;

            if (!_registeredHandlers.TryGetValue(messageTypeId, out existingHandlers))
            {
                existingHandlers = new List <ObjectMessageHandler>();
                _registeredHandlers[messageTypeId] = existingHandlers;
            }
            existingHandlers.Add(handler);
            return(this);
        }