Microscopic Traffic Simulator

- Main Page
- Packages
- Classes
- Files

- File List

Messenger.cs
Go to the documentation of this file.
1 using System;
2 using System.Collections.Generic;
3
4 namespace Microscopic_Traffic_Simulator.ViewModels.Messages
5 {
9 class Messenger
10 {
14 Dictionary<Type, MessageBase> messages = new Dictionary<Type, MessageBase>();
15
21 public TMessage GetEvent<TMessage>() where TMessage : MessageBase
22 {
23 Type messageType = typeof(TMessage);
24 if (messages.ContainsKey(messageType))
25 {
26 return (TMessage)messages[messageType];
27 }
28 else
29 {
30 TMessage message = (TMessage)Activator.CreateInstance(messageType);
31 messages.Add(messageType, message);
32 return message;
33 }
34 }
35 }
36 }
System
Microscopic_Traffic_Simulator.ViewModels.Messages.Messenger
Class representing messenger for communicating between viewmodels.
Definition: Messenger.cs:9
Microscopic_Traffic_Simulator.ViewModels.Messages.MessageBase
Base class for message to be used by messenger.
Definition: MessageBase.cs:7
Microscopic_Traffic_Simulator
Definition: App.xaml.cs:12