File tree Expand file tree Collapse file tree 2 files changed +27
-3
lines changed
src/NServiceBus.Core/Persistence Expand file tree Collapse file tree 2 files changed +27
-3
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ namespace NServiceBus;
66using System . Collections . Generic ;
77using System . Linq ;
88using Features ;
9+ using Persistence ;
910using Logging ;
1011using Settings ;
1112
@@ -51,8 +52,8 @@ public static void ConfigurePersistence(this SettingsHolder settings)
5152
5253 static void ValidateSagaAndOutboxUseSamePersistence ( this SettingsHolder settings , IReadOnlyCollection < EnabledPersistence > enabledPersistences )
5354 {
54- var sagaPersisterDefinition = enabledPersistences . FirstOrDefault ( p => p . SelectedStorages . Contains ( StorageType . Sagas . Instance ) ) ? . Definition ;
55- var outboxPersisterDefinition = enabledPersistences . FirstOrDefault ( p => p . SelectedStorages . Contains ( StorageType . Outbox . Instance ) ) ? . Definition ;
55+ var sagaPersisterDefinition = enabledPersistences . FirstOrDefault ( p => p . SelectedStorages . Contains < StorageType . Sagas > ( ) ) ? . Definition ;
56+ var outboxPersisterDefinition = enabledPersistences . FirstOrDefault ( p => p . SelectedStorages . Contains < StorageType . Outbox > ( ) ) ? . Definition ;
5657 var bothFeaturesEnabled = settings . IsFeatureEnabled ( typeof ( Features . Sagas ) ) && settings . IsFeatureEnabled ( typeof ( Features . Outbox ) ) ;
5758
5859 if ( sagaPersisterDefinition != null
@@ -68,7 +69,7 @@ internal static bool HasSupportFor<T>(this IReadOnlySettings settings) where T :
6869 {
6970 _ = settings . TryGet ( out IReadOnlyCollection < StorageType > supportedStorages ) ;
7071
71- return supportedStorages ? . Contains ( StorageType . Get < T > ( ) ) ?? false ;
72+ return supportedStorages . Contains < T > ( ) ;
7273 }
7374
7475 static readonly ILog Logger = LogManager . GetLogger ( typeof ( PersistenceComponent ) ) ;
Original file line number Diff line number Diff line change 1+ #nullable enable
2+
3+ namespace NServiceBus . Persistence ;
4+
5+ using System . Collections . Generic ;
6+ using System . Linq ;
7+
8+ static class StorageTypeCollectionExtensions
9+ {
10+ extension ( IReadOnlyCollection < StorageType > ? storageTypes )
11+ {
12+ public bool Contains < TStorage > ( ) where TStorage : StorageType
13+ {
14+ if ( storageTypes is null )
15+ {
16+ return false ;
17+ }
18+
19+ var storageType = StorageType . Get < TStorage > ( ) ;
20+ return storageTypes . Contains ( storageType ) ;
21+ }
22+ }
23+ }
You can’t perform that action at this time.
0 commit comments