com.wallstop-studios.dxmessaging 2.1.2 → 2.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/dotnet-tests.yml +1 -1
- package/AGENTS.md +12 -12
- package/Docs/Comparisons.md +5 -5
- package/Docs/InterceptorsAndOrdering.md +1 -1
- package/Docs/Performance.md +13 -13
- package/Docs/QuickReference.md +1 -1
- package/Docs/Reference.md +5 -5
- package/Editor/Analyzers/WallstopStudios.DxMessaging.SourceGenerators.dll +0 -0
- package/Editor/CustomEditors/MessagingComponentEditor.cs +3 -0
- package/Editor/DxMessagingEditorInitializer.cs +58 -1
- package/Editor/DxMessagingMenu.cs +38 -0
- package/Editor/DxMessagingMenu.cs.meta +11 -0
- package/Editor/DxMessagingSceneBuildProcessor.cs +81 -0
- package/Editor/DxMessagingSceneBuildProcessor.cs.meta +11 -0
- package/Editor/Settings/DxMessagingSettings.cs +37 -6
- package/Editor/Settings/DxMessagingSettingsProvider.cs +45 -7
- package/README.md +1 -1
- package/Runtime/Core/Attributes/DxOptionalParameterAttribute.cs +52 -0
- package/Runtime/Core/DataStructure/CyclicBuffer.cs +16 -0
- package/Runtime/Core/Diagnostics/MessageEmissionData.cs +1 -1
- package/Runtime/Core/Diagnostics/MessageRegistrationType.cs +62 -0
- package/Runtime/Core/DxMessagingStaticState.cs +108 -0
- package/Runtime/Core/DxMessagingStaticState.cs.meta +11 -0
- package/Runtime/Core/Extensions/IListExtensions.cs +24 -0
- package/Runtime/Core/Extensions/MessageBusExtensions.cs +142 -0
- package/Runtime/Core/Helper/MessageCache.cs +16 -0
- package/Runtime/Core/Helper/MessageHelperIndexer.cs +77 -0
- package/Runtime/Core/InstanceId.cs +86 -0
- package/Runtime/Core/MessageBus/DiagnosticsTarget.cs +31 -0
- package/Runtime/Core/MessageBus/DiagnosticsTarget.cs.meta +11 -0
- package/Runtime/Core/MessageBus/IMessageBus.cs +44 -16
- package/Runtime/Core/MessageBus/MessageBus.cs +92 -21
- package/Runtime/Core/MessageBus/MessageRegistrationBuilder.cs +44 -0
- package/Runtime/Core/MessageBus/MessagingRegistration.cs +60 -2
- package/Runtime/Core/MessageBus/RegistrationLog.cs +10 -0
- package/Runtime/Core/MessageHandler.cs +107 -6
- package/Runtime/Core/MessageRegistrationHandle.cs +59 -0
- package/Runtime/Core/MessageRegistrationToken.cs +18 -2
- package/Runtime/Core/Messages/ReflexiveMessage.cs +38 -0
- package/Runtime/Core/MessagingDebug.cs +16 -1
- package/Runtime/Unity/CurrentGlobalMessageBusProvider.cs +4 -0
- package/Runtime/Unity/DxMessagingRuntimeInitializer.cs +19 -0
- package/Runtime/Unity/DxMessagingRuntimeInitializer.cs.meta +11 -0
- package/Runtime/Unity/InitialGlobalMessageBusProvider.cs +4 -0
- package/Runtime/Unity/Integrations/Reflex/ReflexRegistrationInstaller.cs +17 -0
- package/Runtime/Unity/Integrations/VContainer/VContainerRegistrationExtensions.cs +8 -0
- package/Runtime/Unity/Integrations/Zenject/ZenjectRegistrationInstaller.cs +12 -0
- package/Runtime/Unity/MessagingComponent.cs +93 -0
- package/Samples~/DI/README.md +13 -13
- package/Samples~/Mini Combat/README.md +15 -15
- package/Samples~/Mini Combat/Walkthrough.md +12 -12
- package/Samples~/UI Buttons + Inspector/README.md +4 -4
- package/SourceGenerators/WallstopStudios.DxMessaging.SourceGenerators/DxAutoConstructorGenerator.cs +4 -0
- package/SourceGenerators/WallstopStudios.DxMessaging.SourceGenerators/DxMessageIdGenerator.cs +4 -0
- package/Tests/Runtime/Core/DiagnosticsTests.cs +3 -3
- package/Tests/Runtime/Core/DxMessagingStaticStateTests.cs +69 -0
- package/Tests/Runtime/Core/DxMessagingStaticStateTests.cs.meta +11 -0
- package/package.json +1 -1
- package/Tests/Runtime/WallstopStudios.DxMessaging.Tests.Runtime.csproj +0 -20
- package/Tests/Runtime/WallstopStudios.DxMessaging.Tests.Runtime.csproj.meta +0 -7
|
@@ -32,6 +32,19 @@ namespace DxMessaging.Core.MessageBus
|
|
|
32
32
|
public long version;
|
|
33
33
|
public long lastSeenVersion = -1;
|
|
34
34
|
public long lastSeenEmissionId;
|
|
35
|
+
|
|
36
|
+
/// <summary>
|
|
37
|
+
/// Clears all cached handler references and resets the version tracking metadata.
|
|
38
|
+
/// </summary>
|
|
39
|
+
public void Clear()
|
|
40
|
+
{
|
|
41
|
+
handlers.Clear();
|
|
42
|
+
order.Clear();
|
|
43
|
+
cache.Clear();
|
|
44
|
+
version = 0;
|
|
45
|
+
lastSeenVersion = -1;
|
|
46
|
+
lastSeenEmissionId = 0;
|
|
47
|
+
}
|
|
35
48
|
}
|
|
36
49
|
|
|
37
50
|
private sealed class HandlerCache
|
|
@@ -41,6 +54,18 @@ namespace DxMessaging.Core.MessageBus
|
|
|
41
54
|
public long version;
|
|
42
55
|
public long lastSeenVersion = -1;
|
|
43
56
|
public long lastSeenEmissionId;
|
|
57
|
+
|
|
58
|
+
/// <summary>
|
|
59
|
+
/// Clears all cached handler references and resets the version tracking metadata.
|
|
60
|
+
/// </summary>
|
|
61
|
+
public void Clear()
|
|
62
|
+
{
|
|
63
|
+
handlers.Clear();
|
|
64
|
+
cache.Clear();
|
|
65
|
+
version = 0;
|
|
66
|
+
lastSeenVersion = -1;
|
|
67
|
+
lastSeenEmissionId = 0;
|
|
68
|
+
}
|
|
44
69
|
}
|
|
45
70
|
|
|
46
71
|
public int RegisteredTargeted
|
|
@@ -48,14 +73,11 @@ namespace DxMessaging.Core.MessageBus
|
|
|
48
73
|
get
|
|
49
74
|
{
|
|
50
75
|
int count = 0;
|
|
51
|
-
|
|
52
|
-
Dictionary<InstanceId, HandlerCache<int, HandlerCache>>
|
|
53
|
-
|
|
54
|
-
while (enumeratorT.MoveNext())
|
|
76
|
+
foreach (
|
|
77
|
+
Dictionary<InstanceId, HandlerCache<int, HandlerCache>> entry in _targetedSinks
|
|
78
|
+
)
|
|
55
79
|
{
|
|
56
|
-
|
|
57
|
-
enumeratorT.Current;
|
|
58
|
-
count += entry.Count;
|
|
80
|
+
count += entry?.Count ?? 0;
|
|
59
81
|
}
|
|
60
82
|
|
|
61
83
|
return count;
|
|
@@ -69,14 +91,11 @@ namespace DxMessaging.Core.MessageBus
|
|
|
69
91
|
get
|
|
70
92
|
{
|
|
71
93
|
int count = 0;
|
|
72
|
-
|
|
73
|
-
Dictionary<InstanceId, HandlerCache<int, HandlerCache>>
|
|
74
|
-
|
|
75
|
-
while (enumeratorB.MoveNext())
|
|
94
|
+
foreach (
|
|
95
|
+
Dictionary<InstanceId, HandlerCache<int, HandlerCache>> entry in _broadcastSinks
|
|
96
|
+
)
|
|
76
97
|
{
|
|
77
|
-
|
|
78
|
-
enumeratorB.Current;
|
|
79
|
-
count += entry.Count;
|
|
98
|
+
count += entry?.Count ?? 0;
|
|
80
99
|
}
|
|
81
100
|
|
|
82
101
|
return count;
|
|
@@ -88,13 +107,9 @@ namespace DxMessaging.Core.MessageBus
|
|
|
88
107
|
get
|
|
89
108
|
{
|
|
90
109
|
int count = 0;
|
|
91
|
-
|
|
92
|
-
HandlerCache<int, HandlerCache>
|
|
93
|
-
>.MessageCacheEnumerator enumeratorU = _sinks.GetEnumerator();
|
|
94
|
-
while (enumeratorU.MoveNext())
|
|
110
|
+
foreach (HandlerCache<int, HandlerCache> entry in _sinks)
|
|
95
111
|
{
|
|
96
|
-
|
|
97
|
-
count += entry.handlers.Count;
|
|
112
|
+
count += entry?.handlers?.Count ?? 0;
|
|
98
113
|
}
|
|
99
114
|
|
|
100
115
|
return count;
|
|
@@ -177,9 +192,46 @@ namespace DxMessaging.Core.MessageBus
|
|
|
177
192
|
GlobalMessageBufferSize
|
|
178
193
|
);
|
|
179
194
|
|
|
180
|
-
private bool _diagnosticsMode =
|
|
195
|
+
private bool _diagnosticsMode = IMessageBus.ShouldEnableDiagnostics();
|
|
181
196
|
private bool _loggedReflexiveWarning;
|
|
182
197
|
|
|
198
|
+
internal void ResetState()
|
|
199
|
+
{
|
|
200
|
+
_emissionId = 0;
|
|
201
|
+
_diagnosticsMode = IMessageBus.ShouldEnableDiagnostics();
|
|
202
|
+
_loggedReflexiveWarning = false;
|
|
203
|
+
|
|
204
|
+
_sinks.Clear();
|
|
205
|
+
_targetedSinks.Clear();
|
|
206
|
+
_broadcastSinks.Clear();
|
|
207
|
+
_postProcessingSinks.Clear();
|
|
208
|
+
_postProcessingTargetedSinks.Clear();
|
|
209
|
+
_postProcessingBroadcastSinks.Clear();
|
|
210
|
+
_postProcessingTargetedWithoutTargetingSinks.Clear();
|
|
211
|
+
_postProcessingBroadcastWithoutSourceSinks.Clear();
|
|
212
|
+
_globalSinks.Clear();
|
|
213
|
+
|
|
214
|
+
_untargetedInterceptsByType.Clear();
|
|
215
|
+
_targetedInterceptsByType.Clear();
|
|
216
|
+
_broadcastInterceptsByType.Clear();
|
|
217
|
+
_uniqueInterceptorsAndPriorities.Clear();
|
|
218
|
+
_broadcastMethodsByType.Clear();
|
|
219
|
+
_innerInterceptorsStack.Clear();
|
|
220
|
+
_methodCache.Clear();
|
|
221
|
+
|
|
222
|
+
#if UNITY_2021_3_OR_NEWER
|
|
223
|
+
_recipientCache.Clear();
|
|
224
|
+
_componentCache.Clear();
|
|
225
|
+
#endif
|
|
226
|
+
|
|
227
|
+
bool enabled = _log.Enabled;
|
|
228
|
+
_log.Clear();
|
|
229
|
+
_log.Enabled = enabled;
|
|
230
|
+
_emissionBuffer.Resize(GlobalMessageBufferSize);
|
|
231
|
+
_emissionBuffer.Clear();
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/// <inheritdoc />
|
|
183
235
|
public Action RegisterUntargeted<T>(MessageHandler messageHandler, int priority = 0)
|
|
184
236
|
where T : IUntargetedMessage
|
|
185
237
|
{
|
|
@@ -191,6 +243,7 @@ namespace DxMessaging.Core.MessageBus
|
|
|
191
243
|
);
|
|
192
244
|
}
|
|
193
245
|
|
|
246
|
+
/// <inheritdoc />
|
|
194
247
|
public Action RegisterTargeted<T>(
|
|
195
248
|
InstanceId target,
|
|
196
249
|
MessageHandler messageHandler,
|
|
@@ -207,6 +260,7 @@ namespace DxMessaging.Core.MessageBus
|
|
|
207
260
|
);
|
|
208
261
|
}
|
|
209
262
|
|
|
263
|
+
/// <inheritdoc />
|
|
210
264
|
public Action RegisterSourcedBroadcast<T>(
|
|
211
265
|
InstanceId source,
|
|
212
266
|
MessageHandler messageHandler,
|
|
@@ -223,6 +277,7 @@ namespace DxMessaging.Core.MessageBus
|
|
|
223
277
|
);
|
|
224
278
|
}
|
|
225
279
|
|
|
280
|
+
/// <inheritdoc />
|
|
226
281
|
public Action RegisterSourcedBroadcastWithoutSource<T>(
|
|
227
282
|
MessageHandler messageHandler,
|
|
228
283
|
int priority = 0
|
|
@@ -237,6 +292,7 @@ namespace DxMessaging.Core.MessageBus
|
|
|
237
292
|
);
|
|
238
293
|
}
|
|
239
294
|
|
|
295
|
+
/// <inheritdoc />
|
|
240
296
|
public Action RegisterTargetedWithoutTargeting<T>(
|
|
241
297
|
MessageHandler messageHandler,
|
|
242
298
|
int priority = 0
|
|
@@ -251,6 +307,7 @@ namespace DxMessaging.Core.MessageBus
|
|
|
251
307
|
);
|
|
252
308
|
}
|
|
253
309
|
|
|
310
|
+
/// <inheritdoc />
|
|
254
311
|
public Action RegisterGlobalAcceptAll(MessageHandler messageHandler)
|
|
255
312
|
{
|
|
256
313
|
_globalSinks.version++;
|
|
@@ -303,6 +360,7 @@ namespace DxMessaging.Core.MessageBus
|
|
|
303
360
|
};
|
|
304
361
|
}
|
|
305
362
|
|
|
363
|
+
/// <inheritdoc />
|
|
306
364
|
public Action RegisterUntargetedInterceptor<T>(
|
|
307
365
|
UntargetedInterceptor<T> interceptor,
|
|
308
366
|
int priority = 0
|
|
@@ -436,6 +494,7 @@ namespace DxMessaging.Core.MessageBus
|
|
|
436
494
|
};
|
|
437
495
|
}
|
|
438
496
|
|
|
497
|
+
/// <inheritdoc />
|
|
439
498
|
public Action RegisterTargetedInterceptor<T>(
|
|
440
499
|
TargetedInterceptor<T> interceptor,
|
|
441
500
|
int priority = 0
|
|
@@ -569,6 +628,7 @@ namespace DxMessaging.Core.MessageBus
|
|
|
569
628
|
};
|
|
570
629
|
}
|
|
571
630
|
|
|
631
|
+
/// <inheritdoc />
|
|
572
632
|
public Action RegisterBroadcastInterceptor<T>(
|
|
573
633
|
BroadcastInterceptor<T> interceptor,
|
|
574
634
|
int priority = 0
|
|
@@ -702,6 +762,7 @@ namespace DxMessaging.Core.MessageBus
|
|
|
702
762
|
};
|
|
703
763
|
}
|
|
704
764
|
|
|
765
|
+
/// <inheritdoc />
|
|
705
766
|
public Action RegisterUntargetedPostProcessor<T>(
|
|
706
767
|
MessageHandler messageHandler,
|
|
707
768
|
int priority = 0
|
|
@@ -716,6 +777,7 @@ namespace DxMessaging.Core.MessageBus
|
|
|
716
777
|
);
|
|
717
778
|
}
|
|
718
779
|
|
|
780
|
+
/// <inheritdoc />
|
|
719
781
|
public Action RegisterTargetedPostProcessor<T>(
|
|
720
782
|
InstanceId target,
|
|
721
783
|
MessageHandler messageHandler,
|
|
@@ -732,6 +794,7 @@ namespace DxMessaging.Core.MessageBus
|
|
|
732
794
|
);
|
|
733
795
|
}
|
|
734
796
|
|
|
797
|
+
/// <inheritdoc />
|
|
735
798
|
public Action RegisterTargetedWithoutTargetingPostProcessor<T>(
|
|
736
799
|
MessageHandler messageHandler,
|
|
737
800
|
int priority = 0
|
|
@@ -746,6 +809,7 @@ namespace DxMessaging.Core.MessageBus
|
|
|
746
809
|
);
|
|
747
810
|
}
|
|
748
811
|
|
|
812
|
+
/// <inheritdoc />
|
|
749
813
|
public Action RegisterBroadcastPostProcessor<T>(
|
|
750
814
|
InstanceId source,
|
|
751
815
|
MessageHandler messageHandler,
|
|
@@ -762,6 +826,7 @@ namespace DxMessaging.Core.MessageBus
|
|
|
762
826
|
);
|
|
763
827
|
}
|
|
764
828
|
|
|
829
|
+
/// <inheritdoc />
|
|
765
830
|
public Action RegisterBroadcastWithoutSourcePostProcessor<T>(
|
|
766
831
|
MessageHandler messageHandler,
|
|
767
832
|
int priority = 0
|
|
@@ -778,6 +843,7 @@ namespace DxMessaging.Core.MessageBus
|
|
|
778
843
|
|
|
779
844
|
// Legacy RegisterInterceptor removed in favor of split implementations above
|
|
780
845
|
|
|
846
|
+
/// <inheritdoc />
|
|
781
847
|
public void UntypedUntargetedBroadcast(IUntargetedMessage typedMessage)
|
|
782
848
|
{
|
|
783
849
|
Type messageType = typedMessage.MessageType;
|
|
@@ -807,6 +873,7 @@ namespace DxMessaging.Core.MessageBus
|
|
|
807
873
|
broadcast.Invoke(typedMessage);
|
|
808
874
|
}
|
|
809
875
|
|
|
876
|
+
/// <inheritdoc />
|
|
810
877
|
public void UntargetedBroadcast<TMessage>(ref TMessage typedMessage)
|
|
811
878
|
where TMessage : IUntargetedMessage
|
|
812
879
|
{
|
|
@@ -1010,6 +1077,7 @@ namespace DxMessaging.Core.MessageBus
|
|
|
1010
1077
|
}
|
|
1011
1078
|
}
|
|
1012
1079
|
|
|
1080
|
+
/// <inheritdoc />
|
|
1013
1081
|
public void UntypedTargetedBroadcast(InstanceId target, ITargetedMessage typedMessage)
|
|
1014
1082
|
{
|
|
1015
1083
|
Type messageType = typedMessage.MessageType;
|
|
@@ -1039,6 +1107,7 @@ namespace DxMessaging.Core.MessageBus
|
|
|
1039
1107
|
broadcast.Invoke(target, typedMessage);
|
|
1040
1108
|
}
|
|
1041
1109
|
|
|
1110
|
+
/// <inheritdoc />
|
|
1042
1111
|
public void TargetedBroadcast<TMessage>(ref InstanceId target, ref TMessage typedMessage)
|
|
1043
1112
|
where TMessage : ITargetedMessage
|
|
1044
1113
|
{
|
|
@@ -2047,6 +2116,7 @@ namespace DxMessaging.Core.MessageBus
|
|
|
2047
2116
|
}
|
|
2048
2117
|
}
|
|
2049
2118
|
|
|
2119
|
+
/// <inheritdoc />
|
|
2050
2120
|
public void UntypedSourcedBroadcast(InstanceId source, IBroadcastMessage typedMessage)
|
|
2051
2121
|
{
|
|
2052
2122
|
Type messageType = typedMessage.MessageType;
|
|
@@ -2079,6 +2149,7 @@ namespace DxMessaging.Core.MessageBus
|
|
|
2079
2149
|
broadcast.Invoke(source, typedMessage);
|
|
2080
2150
|
}
|
|
2081
2151
|
|
|
2152
|
+
/// <inheritdoc />
|
|
2082
2153
|
public void SourcedBroadcast<TMessage>(ref InstanceId source, ref TMessage typedMessage)
|
|
2083
2154
|
where TMessage : IBroadcastMessage
|
|
2084
2155
|
{
|
|
@@ -99,6 +99,13 @@ namespace DxMessaging.Core.MessageBus
|
|
|
99
99
|
/// </remarks>
|
|
100
100
|
public readonly struct MessageRegistrationLifecycle
|
|
101
101
|
{
|
|
102
|
+
/// <summary>
|
|
103
|
+
/// Creates a lifecycle definition with the supplied callbacks.
|
|
104
|
+
/// </summary>
|
|
105
|
+
/// <param name="onBuild">Invoked immediately after the lease is constructed.</param>
|
|
106
|
+
/// <param name="onActivate">Invoked when the lease becomes active.</param>
|
|
107
|
+
/// <param name="onDeactivate">Invoked when the lease transitions from active to inactive.</param>
|
|
108
|
+
/// <param name="onDispose">Invoked during lease disposal.</param>
|
|
102
109
|
public MessageRegistrationLifecycle(
|
|
103
110
|
Action<MessageRegistrationToken> onBuild,
|
|
104
111
|
Action<MessageRegistrationToken> onActivate,
|
|
@@ -201,6 +208,9 @@ namespace DxMessaging.Core.MessageBus
|
|
|
201
208
|
_isActive = true;
|
|
202
209
|
}
|
|
203
210
|
|
|
211
|
+
/// <summary>
|
|
212
|
+
/// Deactivates the lease, unregistering staged handlers and invoking lifecycle hooks.
|
|
213
|
+
/// </summary>
|
|
204
214
|
public void Deactivate()
|
|
205
215
|
{
|
|
206
216
|
if (_disposed || !_isActive)
|
|
@@ -218,6 +228,9 @@ namespace DxMessaging.Core.MessageBus
|
|
|
218
228
|
_isActive = false;
|
|
219
229
|
}
|
|
220
230
|
|
|
231
|
+
/// <summary>
|
|
232
|
+
/// Disposes the lease, unregistering handlers and executing lifecycle callbacks once.
|
|
233
|
+
/// </summary>
|
|
221
234
|
public void Dispose()
|
|
222
235
|
{
|
|
223
236
|
if (_disposed)
|
|
@@ -259,11 +272,33 @@ namespace DxMessaging.Core.MessageBus
|
|
|
259
272
|
private readonly IMessageBusProvider _messageBusProvider;
|
|
260
273
|
private static int _syntheticOwnerCounter;
|
|
261
274
|
|
|
275
|
+
internal static int GetSyntheticOwnerCounter()
|
|
276
|
+
{
|
|
277
|
+
return Volatile.Read(ref _syntheticOwnerCounter);
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
internal static void SetSyntheticOwnerCounter(int value)
|
|
281
|
+
{
|
|
282
|
+
_ = Interlocked.Exchange(ref _syntheticOwnerCounter, value);
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
internal static void ResetSyntheticOwnerCounter()
|
|
286
|
+
{
|
|
287
|
+
SetSyntheticOwnerCounter(0);
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
/// <summary>
|
|
291
|
+
/// Initializes a builder that resolves buses from global state.
|
|
292
|
+
/// </summary>
|
|
262
293
|
public MessageRegistrationBuilder()
|
|
263
294
|
{
|
|
264
295
|
_messageBusProvider = null;
|
|
265
296
|
}
|
|
266
297
|
|
|
298
|
+
/// <summary>
|
|
299
|
+
/// Initializes a builder that uses a custom bus provider.
|
|
300
|
+
/// </summary>
|
|
301
|
+
/// <param name="messageBusProvider">Provider used to resolve message buses for new leases.</param>
|
|
267
302
|
public MessageRegistrationBuilder(IMessageBusProvider messageBusProvider)
|
|
268
303
|
{
|
|
269
304
|
_messageBusProvider = messageBusProvider;
|
|
@@ -370,11 +405,20 @@ namespace DxMessaging.Core.MessageBus
|
|
|
370
405
|
{
|
|
371
406
|
private readonly IMessageBus _messageBus;
|
|
372
407
|
|
|
408
|
+
/// <summary>
|
|
409
|
+
/// Creates a provider that always returns the supplied bus instance.
|
|
410
|
+
/// </summary>
|
|
411
|
+
/// <param name="messageBus">Bus instance to return when <see cref="Resolve"/> is invoked.</param>
|
|
412
|
+
/// <exception cref="ArgumentNullException">Thrown when <paramref name="messageBus"/> is null.</exception>
|
|
373
413
|
public FixedMessageBusProvider(IMessageBus messageBus)
|
|
374
414
|
{
|
|
375
415
|
_messageBus = messageBus ?? throw new ArgumentNullException(nameof(messageBus));
|
|
376
416
|
}
|
|
377
417
|
|
|
418
|
+
/// <summary>
|
|
419
|
+
/// Resolves the configured message bus.
|
|
420
|
+
/// </summary>
|
|
421
|
+
/// <returns>The bus supplied during construction.</returns>
|
|
378
422
|
public IMessageBus Resolve()
|
|
379
423
|
{
|
|
380
424
|
return _messageBus;
|
|
@@ -4,30 +4,84 @@ namespace DxMessaging.Core.MessageBus
|
|
|
4
4
|
using System.Runtime.Serialization;
|
|
5
5
|
|
|
6
6
|
/// <summary>
|
|
7
|
-
///
|
|
7
|
+
/// Indicates whether a registration was added or removed.
|
|
8
8
|
/// </summary>
|
|
9
9
|
public enum RegistrationType
|
|
10
10
|
{
|
|
11
|
+
/// <summary>
|
|
12
|
+
/// The registration was added to the bus.
|
|
13
|
+
/// </summary>
|
|
11
14
|
Register,
|
|
15
|
+
|
|
16
|
+
/// <summary>
|
|
17
|
+
/// The registration was removed from the bus.
|
|
18
|
+
/// </summary>
|
|
12
19
|
Deregister,
|
|
13
20
|
}
|
|
14
21
|
|
|
15
22
|
/// <summary>
|
|
16
|
-
/// Exact
|
|
23
|
+
/// Exact registration category used when the handler was wired up.
|
|
17
24
|
/// </summary>
|
|
18
25
|
public enum RegistrationMethod
|
|
19
26
|
{
|
|
27
|
+
/// <summary>
|
|
28
|
+
/// Registered as a targeted handler bound to a specific recipient.
|
|
29
|
+
/// </summary>
|
|
20
30
|
Targeted,
|
|
31
|
+
|
|
32
|
+
/// <summary>
|
|
33
|
+
/// Registered as a global untargeted handler.
|
|
34
|
+
/// </summary>
|
|
21
35
|
Untargeted,
|
|
36
|
+
|
|
37
|
+
/// <summary>
|
|
38
|
+
/// Registered as a broadcast handler bound to a specific source.
|
|
39
|
+
/// </summary>
|
|
22
40
|
Broadcast,
|
|
41
|
+
|
|
42
|
+
/// <summary>
|
|
43
|
+
/// Registered as a broadcast handler without an explicit source.
|
|
44
|
+
/// </summary>
|
|
23
45
|
BroadcastWithoutSource,
|
|
46
|
+
|
|
47
|
+
/// <summary>
|
|
48
|
+
/// Registered as a targeted handler that ignores the runtime target.
|
|
49
|
+
/// </summary>
|
|
24
50
|
TargetedWithoutTargeting,
|
|
51
|
+
|
|
52
|
+
/// <summary>
|
|
53
|
+
/// Registered as a global catch-all handler.
|
|
54
|
+
/// </summary>
|
|
25
55
|
GlobalAcceptAll,
|
|
56
|
+
|
|
57
|
+
/// <summary>
|
|
58
|
+
/// Registered as an interceptor (exact type recorded separately).
|
|
59
|
+
/// </summary>
|
|
26
60
|
Interceptor,
|
|
61
|
+
|
|
62
|
+
/// <summary>
|
|
63
|
+
/// Registered as a post-processor for untargeted messages.
|
|
64
|
+
/// </summary>
|
|
27
65
|
UntargetedPostProcessor,
|
|
66
|
+
|
|
67
|
+
/// <summary>
|
|
68
|
+
/// Registered as a post-processor for targeted messages.
|
|
69
|
+
/// </summary>
|
|
28
70
|
TargetedPostProcessor,
|
|
71
|
+
|
|
72
|
+
/// <summary>
|
|
73
|
+
/// Registered as a post-processor for broadcast messages.
|
|
74
|
+
/// </summary>
|
|
29
75
|
BroadcastPostProcessor,
|
|
76
|
+
|
|
77
|
+
/// <summary>
|
|
78
|
+
/// Registered as a post-processor for targeted messages that ignore the runtime target.
|
|
79
|
+
/// </summary>
|
|
30
80
|
TargetedWithoutTargetingPostProcessor,
|
|
81
|
+
|
|
82
|
+
/// <summary>
|
|
83
|
+
/// Registered as a post-processor for broadcasts without explicit source information.
|
|
84
|
+
/// </summary>
|
|
31
85
|
BroadcastWithoutSourcePostProcessor,
|
|
32
86
|
}
|
|
33
87
|
|
|
@@ -88,6 +142,10 @@ namespace DxMessaging.Core.MessageBus
|
|
|
88
142
|
#endif
|
|
89
143
|
}
|
|
90
144
|
|
|
145
|
+
/// <summary>
|
|
146
|
+
/// Returns a descriptive string that includes key registration metadata for diagnostics.
|
|
147
|
+
/// </summary>
|
|
148
|
+
/// <returns>Human-readable summary of this registration entry.</returns>
|
|
91
149
|
public override string ToString()
|
|
92
150
|
{
|
|
93
151
|
return new
|
|
@@ -26,6 +26,12 @@ namespace DxMessaging.Core.MessageBus
|
|
|
26
26
|
|
|
27
27
|
private bool _enabled;
|
|
28
28
|
|
|
29
|
+
/// <summary>
|
|
30
|
+
/// Creates a new registration log.
|
|
31
|
+
/// </summary>
|
|
32
|
+
/// <param name="enabled">
|
|
33
|
+
/// When <c>true</c>, logging starts immediately; otherwise call <see cref="Enabled"/> to enable later.
|
|
34
|
+
/// </param>
|
|
29
35
|
public RegistrationLog(bool enabled = false)
|
|
30
36
|
{
|
|
31
37
|
_enabled = enabled;
|
|
@@ -92,6 +98,10 @@ namespace DxMessaging.Core.MessageBus
|
|
|
92
98
|
return registrations.ToString();
|
|
93
99
|
}
|
|
94
100
|
|
|
101
|
+
/// <summary>
|
|
102
|
+
/// Serializes the log using the default formatter (<see cref="MessagingRegistration.ToString"/>).
|
|
103
|
+
/// </summary>
|
|
104
|
+
/// <returns>String containing all recorded registrations.</returns>
|
|
95
105
|
public override string ToString()
|
|
96
106
|
{
|
|
97
107
|
return ToString(null);
|