Class MessageDomain
The time domain the message is operating in.
Namespace: Agents.Net
Assembly: Agents.Net.dll
Syntax
public class MessageDomain : IEquatable<MessageDomain>
Remarks
Each message operates in a specific message domain. Usually that is the DefaultMessageDomain. But there are situations where it is necessary to specify new domains for a message. Some of these situations are:
- when message are executed explicitly in parallel with OnMessages(IReadOnlyCollection<Message>) in order to aggregate them again
- when a sequential cycle of recurring message chains is executed in order to identify the start of the cycle when the next cycle starts
- to separate message produced in a specific chain (e.g. UIEvent) from other messages
Given is the following example:
--------------- ------------
| DefaultDomain | ----> | SubDomain1 |
--------------- | ------------
T1 Message1 | T1 Message2
| T2 Message4
|
| ------------
----> | SubDomain2 |
------------
T2 Message3
T2 Message5
Message2 and Message4 should never be used in SubDomain2 as well as Message3 and Message5 should never be used in SubDomain1. But Message1 is accessible from all domains. The MessageCollector<T1, T2> implements these rules.
New messages inherit the domain for their predecessors. That means if there is a new message based on the messages Message1 and Message4 it is automatically in the SubDomain1 as long as that domain is still active. Trying to create a new message based on the messages Message2 and Message3 will result in an exception as these are sibling domains which cannot interfere with each other.
Properties
| Improve this Doc View SourceChildren
The child domains that were created in this domain.
Declaration
public IReadOnlyCollection<MessageDomain> Children { get; }
Property Value
Type | Description |
---|---|
IReadOnlyCollection<MessageDomain> |
DefaultMessageDomain
The default message domain for all new messages.
Declaration
public static MessageDomain DefaultMessageDomain { get; }
Property Value
Type | Description |
---|---|
MessageDomain |
IsTerminated
If set to true
, shows that the domain was terminated.
Declaration
public bool IsTerminated { get; }
Property Value
Type | Description |
---|---|
Boolean |
Parent
The parent domain.
Declaration
public MessageDomain Parent { get; }
Property Value
Type | Description |
---|---|
MessageDomain |
Root
The first message of the domain.
Declaration
public Message Root { get; }
Property Value
Type | Description |
---|---|
Message |
SiblingDomainRootMessages
The root messages of all message domains that were created together with this domain.
Declaration
public IReadOnlyCollection<Message> SiblingDomainRootMessages { get; }
Property Value
Type | Description |
---|---|
IReadOnlyCollection<Message> |
Remarks
There can be more sibling domains active. This will only contain all sibling domains that were created with the CreateNewDomainsFor(IReadOnlyCollection<Message>) method.
Methods
| Improve this Doc View SourceCreateNewDomainsFor(Message)
Create a new domain for the newDomainRootMessage
.
Declaration
public static void CreateNewDomainsFor(Message newDomainRootMessage)
Parameters
Type | Name | Description |
---|---|---|
Message | newDomainRootMessage | The first message in the new domain. |
CreateNewDomainsFor(IReadOnlyCollection<Message>)
Create a new domain for each of the newDomainRootMessages
.
Declaration
public static void CreateNewDomainsFor(IReadOnlyCollection<Message> newDomainRootMessages)
Parameters
Type | Name | Description |
---|---|---|
IReadOnlyCollection<Message> | newDomainRootMessages | The first messages in the new domains. |
Equals(MessageDomain)
Declaration
public bool Equals(MessageDomain other)
Parameters
Type | Name | Description |
---|---|---|
MessageDomain | other |
Returns
Type | Description |
---|---|
Boolean |
Equals(Object)
Declaration
public override bool Equals(object obj)
Parameters
Type | Name | Description |
---|---|---|
Object | obj |
Returns
Type | Description |
---|---|
Boolean |
GetHashCode()
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
Int32 |
TerminateDomainsOf(Message)
Sets the domain of domainMessage
to inactive.
Declaration
public static void TerminateDomainsOf(Message domainMessage)
Parameters
Type | Name | Description |
---|---|---|
Message | domainMessage | The message which provides the terminated domain. |
TerminateDomainsOf(IReadOnlyCollection<Message>)
Sets the domain of all domainMessages
to inactive.
Declaration
public static void TerminateDomainsOf(IReadOnlyCollection<Message> domainMessages)
Parameters
Type | Name | Description |
---|---|---|
IReadOnlyCollection<Message> | domainMessages | The messages which provides the terminated domains. |
Operators
| Improve this Doc View SourceEquality(MessageDomain, MessageDomain)
Checks whether both domains are equal.
Declaration
public static bool operator ==(MessageDomain left, MessageDomain right)
Parameters
Type | Name | Description |
---|---|---|
MessageDomain | left | The first domain. |
MessageDomain | right | The second domain. |
Returns
Type | Description |
---|---|
Boolean |
|
Inequality(MessageDomain, MessageDomain)
Checks whether both domains are not equal.
Declaration
public static bool operator !=(MessageDomain left, MessageDomain right)
Parameters
Type | Name | Description |
---|---|---|
MessageDomain | left | The first domain. |
MessageDomain | right | The second domain. |
Returns
Type | Description |
---|---|
Boolean |
|