Microscopic Traffic Simulator

- Main Page
- Packages
- Classes
- Files

- File List

Message.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 abstract class Message : MessageBase
10 {
14 private HashSet<Action> subscribers = new HashSet<Action>();
15
20 internal void Subscribe(Action subscriber)
21 {
22 subscribers.Add(subscriber);
23 }
24
29 internal void Unsubcsribe(Action subscriber)
30 {
31 subscribers.Remove(subscriber);
32 }
33
37 internal void Publish()
38 {
39 foreach (Action subscriber in subscribers)
40 {
41 subscriber();
42 }
43 }
44 }
45 }
System
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
Microscopic_Traffic_Simulator.ViewModels.Messages.Message
Class representing message without payload.
Definition: Message.cs:9