-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make IMessage serializer overridable
- Loading branch information
Showing
9 changed files
with
50 additions
and
18 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#nullable enable | ||
using System; | ||
using ServiceStack.Messaging; | ||
|
||
namespace ServiceStack; | ||
|
||
public class MessageSerializer | ||
{ | ||
public static IMessageSerializer Instance { get; set; } = new ServiceStackMessageSerializer(); | ||
} | ||
|
||
public class ServiceStackMessageSerializer : IMessageSerializer | ||
{ | ||
public byte[] ToBytes(IMessage message) => message.ToBytes(); | ||
|
||
public byte[] ToBytes<T>(IMessage<T> message) => message.ToBytes(); | ||
|
||
public IMessage ToMessage(byte[] bytes, Type ofType) => bytes.ToMessage(ofType); | ||
|
||
public Message<T> ToMessage<T>(byte[] bytes) => bytes.ToMessage<T>(); | ||
} |
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
14 changes: 14 additions & 0 deletions
14
ServiceStack/src/ServiceStack.Interfaces/Messaging/IMessageSerializer.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,14 @@ | ||
using System; | ||
|
||
namespace ServiceStack.Messaging; | ||
|
||
public interface IMessageSerializer | ||
{ | ||
byte[] ToBytes(IMessage message); | ||
|
||
byte[] ToBytes<T>(IMessage<T> message); | ||
|
||
IMessage ToMessage(byte[] bytes, Type ofType); | ||
|
||
Message<T> ToMessage<T>(byte[] bytes); | ||
} |
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