@@ -49,9 +49,9 @@ public class KurrentDBClientSerializationSettings {
49
49
/// <example>
50
50
/// <code>
51
51
/// var settings = KurrentDBClientSerializationSettings.Default(options => {
52
- /// options.RegisterMessageType <UserCreated >("user-created ");
53
- /// options.RegisterMessageType <UserUpdated >("user-updated ");
54
- /// options.RegisterMessageTypeForCategory <UserCreated >("user ");
52
+ /// options.MessageTypeMapping.Register <UserRegistered >("user_registered ");
53
+ /// options.MessageTypeMapping.Register <RoleAssigned >("role_assigned ");
54
+ /// options.MessageTypeMapping.RegisterForCategory <UserRegistered >("user_onboarding ");
55
55
/// });
56
56
/// </code>
57
57
/// </example>
@@ -196,7 +196,7 @@ internal KurrentDBClientSerializationSettings Clone() {
196
196
BytesSerializer = BytesSerializer ,
197
197
JsonSerializer = JsonSerializer ,
198
198
DefaultContentType = DefaultContentType ,
199
- MessageTypeMapping = MessageTypeMapping . Clone ( ) ,
199
+ MessageTypeMapping = MessageTypeMapping . Clone ( ) ,
200
200
MessageTypeNamingStrategy = MessageTypeNamingStrategy
201
201
} ;
202
202
}
@@ -264,6 +264,25 @@ public enum AutomaticDeserialization {
264
264
Enabled = 1
265
265
}
266
266
267
+ /// <summary>
268
+ /// Controls whether the KurrentDB client should automatically register
269
+ /// message type names based on the CLR type using naming convention.
270
+ /// By default, it's enabled.
271
+ /// </summary>
272
+ public enum AutomaticTypeMappingRegistration {
273
+ /// <summary>
274
+ /// Enables automatic type registration.
275
+ /// The messages will be automatically discovered and resolved using registered naming resolution strategy.
276
+ /// </summary>
277
+ Enabled = 0 ,
278
+
279
+ /// <summary>
280
+ /// Disables automatic type registration. If you use this setting, you need to register all type mappings manually.
281
+ /// If the type mapping is not registered for the specific message, the exception will be thrown.
282
+ /// </summary>
283
+ Disabled = 1
284
+ }
285
+
267
286
/// <summary>
268
287
/// Represents message type mapping settings
269
288
/// </summary>
@@ -277,7 +296,7 @@ public class MessageTypeMappingSettings {
277
296
/// Registers CLR message types that can be appended to the specific stream category.
278
297
/// Types will have message type names resolved based on the used <see cref="KurrentDB.Client.Core.Serialization.IMessageTypeNamingStrategy"/>
279
298
/// </summary>
280
- public IDictionary < string , Type [ ] > CategoryTypesMap { get ; set ; } = new Dictionary < string , Type [ ] > ( ) ;
299
+ internal IDictionary < string , Type [ ] > CategoryTypesMap { get ; set ; } = new Dictionary < string , Type [ ] > ( ) ;
281
300
282
301
/// <summary>
283
302
/// Specifies the CLR type that should be used when deserializing metadata for all events.
@@ -286,6 +305,13 @@ public class MessageTypeMappingSettings {
286
305
/// </summary>
287
306
public Type ? DefaultMetadataType { get ; set ; }
288
307
308
+ /// <summary>
309
+ /// Controls whether the KurrentDB client should automatically register
310
+ /// message type names based on the CLR type using naming convention.
311
+ /// By default, it's enabled.
312
+ /// </summary>
313
+ public AutomaticTypeMappingRegistration ? AutomaticTypeMappingRegistration { get ; set ; }
314
+
289
315
/// <summary>
290
316
/// Associates a message type with a specific stream category to enable automatic deserialization.
291
317
/// In event sourcing, streams are often prefixed with a category (e.g., "user-123", "order-456").
@@ -297,9 +323,9 @@ public class MessageTypeMappingSettings {
297
323
/// <example>
298
324
/// <code>
299
325
/// // Register event types that can appear in user streams
300
- /// settings.RegisterMessageTypeForCategory <UserCreated >("user")
301
- /// .RegisterMessageTypeForCategory <UserUpdated >("user")
302
- /// .RegisterMessageTypeForCategory <UserDeleted>("user");
326
+ /// settings.RegisterForCategory <UserRegistered >("user")
327
+ /// .RegisterForCategory <RoleAssigned >("user")
328
+ /// .RegisterForCategory <UserDeleted>("user");
303
329
/// </code>
304
330
/// </example>
305
331
public MessageTypeMappingSettings RegisterForCategory < T > ( string categoryName ) =>
@@ -335,8 +361,8 @@ public MessageTypeMappingSettings RegisterForCategory(string categoryName, param
335
361
/// <example>
336
362
/// <code>
337
363
/// // Register me types with their corresponding type identifiers
338
- /// settings.RegisterMessageType <UserCreated >("user-created -v1")
339
- /// .RegisterMessageType <OrderPlaced>("order-placed-v2");
364
+ /// settings.Register <UserRegistered >("user_registered -v1")
365
+ /// .Register <OrderPlaced>("order-placed-v2");
340
366
/// </code>
341
367
/// </example>
342
368
public MessageTypeMappingSettings Register < T > ( string typeName ) =>
@@ -387,6 +413,29 @@ public MessageTypeMappingSettings UseMetadataType(Type type) {
387
413
388
414
return this ;
389
415
}
416
+
417
+ /// <summary>
418
+ /// Disables automatic deserialization. Messages will be returned in their raw serialized form,
419
+ /// requiring manual deserialization by the application. Use this when you need direct access to the raw data
420
+ /// or when working with messages that don't have registered type mappings.
421
+ /// </summary>
422
+ /// <returns>The current instance for method chaining.</returns>
423
+ public MessageTypeMappingSettings DisableAutomaticRegistration ( ) {
424
+ AutomaticTypeMappingRegistration = Client . AutomaticTypeMappingRegistration . Disabled ;
425
+
426
+ return this ;
427
+ }
428
+
429
+ /// <summary>
430
+ /// Disables automatic type registration. If you use this setting, you need to register all type mappings manually.
431
+ /// If the type mapping is not registered for the specific message, the exception will be thrown.
432
+ /// </summary>
433
+ /// <returns>The current instance for method chaining.</returns>
434
+ public MessageTypeMappingSettings EnableAutomaticRegistration ( ) {
435
+ AutomaticTypeMappingRegistration = Client . AutomaticTypeMappingRegistration . Enabled ;
436
+
437
+ return this ;
438
+ }
390
439
391
440
internal MessageTypeMappingSettings Clone ( ) =>
392
441
new MessageTypeMappingSettings {
0 commit comments