-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Resolve HybridMessageSerializer dependencies from IServiceProvider
Signed-off-by: Richard Pringle <richard.pringle@gmail.com>
- Loading branch information
Richard Pringle
committed
Apr 4, 2024
1 parent
f061530
commit f29f09e
Showing
12 changed files
with
351 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,30 @@ | ||
# What | ||
|
||
Message serialization that based on message type delegates to the respective serializer. | ||
Message serialization that is based on message type, delegating serialization to the respective serializer. | ||
|
||
```c# | ||
|
||
services | ||
.AddSlimMessageBus(mbb => | ||
{ | ||
mbb | ||
// add required serializers to the DI container first | ||
.AddAvroSerializer() | ||
.AddGoogleProtobufSerializer() | ||
.AddJsonSerializer() | ||
|
||
// Add hybrid serializer last so that it can update DI container and set itself as the default | ||
.AddHybridSerializer<JsonMessageSerializer>( | ||
o => { | ||
|
||
// Message1, Message2 => AvroSerializer | ||
// Message3 => GoogleProtobufMessageSerializer | ||
// all other messages by JsonMessageSerializer | ||
o.Add<AvroSerializer>(typeof(Message1), typeof(Message2)); | ||
o.Add<GoogleProtobufMessageSerializer>(typeof(Message3)); | ||
}) | ||
... | ||
} | ||
|
||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
src/Tests/SlimMessageBus.Host.Serialization.Hybrid.Test/Helpers/SampleMessages.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
namespace SlimMessageBus.Host.Serialization.Hybrid.Test.Helpers | ||
{ | ||
public record SampleOne; | ||
public record SampleTwo; | ||
public record SampleThree; | ||
} |
Oops, something went wrong.