message improvements
parent
ed965d43a3
commit
bd7c316ea8
|
@ -8,26 +8,23 @@ namespace Encompass
|
|||
{
|
||||
private readonly Dictionary<Type, List<IMessage>> messageTypeToMessages = new Dictionary<Type, List<IMessage>>();
|
||||
|
||||
internal void AddMessage<TMessage>(TMessage message) where TMessage : struct, IMessage
|
||||
internal void RegisterMessageType(Type messageType)
|
||||
{
|
||||
if (!messageTypeToMessages.ContainsKey(typeof(TMessage)))
|
||||
{
|
||||
messageTypeToMessages.Add(typeof(TMessage), new List<IMessage>());
|
||||
if (!messageTypeToMessages.ContainsKey(messageType)) {
|
||||
messageTypeToMessages.Add(messageType, new List<IMessage>());
|
||||
}
|
||||
|
||||
messageTypeToMessages[typeof(TMessage)].Add(message);
|
||||
}
|
||||
|
||||
internal void AddMessage(IMessage message)
|
||||
{
|
||||
var type = message.GetType();
|
||||
|
||||
if (!messageTypeToMessages.ContainsKey(type))
|
||||
{
|
||||
messageTypeToMessages.Add(type, new List<IMessage>());
|
||||
messageTypeToMessages[type].Add(message);
|
||||
}
|
||||
|
||||
messageTypeToMessages[type].Add(message);
|
||||
internal void AddMessage<TMessage>(IMessage message) where TMessage : struct, IMessage
|
||||
{
|
||||
messageTypeToMessages[typeof(TMessage)].Add(message);
|
||||
}
|
||||
|
||||
internal void ClearMessages()
|
||||
|
|
|
@ -86,6 +86,11 @@ namespace Encompass
|
|||
var messageReceiveTypes = engine.receiveTypes;
|
||||
var messageSendTypes = engine.sendTypes;
|
||||
|
||||
foreach (var messageType in messageReceiveTypes.Union(messageSendTypes))
|
||||
{
|
||||
messageManager.RegisterMessageType(messageType);
|
||||
}
|
||||
|
||||
foreach (var messageType in messageReceiveTypes.Intersect(messageSendTypes))
|
||||
{
|
||||
if ((messageType.IsGenericType && messageType.GetGenericTypeDefinition() == typeof(PendingComponentMessage<>)))
|
||||
|
|
Loading…
Reference in New Issue