Dreamine.Communication.Core 1.0.2
Dreamine.Communication.Core 통신 기능과 관련 API를 제공합니다.
로딩중...
검색중...
일치하는것 없음
DreamineEnvelopeProtocolAdapter.cs
이 파일의 문서화 페이지로 가기
1using Dreamine.Communication.Abstractions.Interfaces;
2using Dreamine.Communication.Abstractions.Models;
4
6
23public sealed class DreamineEnvelopeProtocolAdapter : IMessageProtocolAdapter
24{
33 private readonly IMessageSerializer _serializer;
34
44 : this(new JsonMessageSerializer())
45 {
46 }
47
72 public DreamineEnvelopeProtocolAdapter(IMessageSerializer serializer)
73 {
74 _serializer = serializer ?? throw new ArgumentNullException(nameof(serializer));
75 }
76
109 public MessageEnvelope Decode(byte[] payload)
110 {
111 ArgumentNullException.ThrowIfNull(payload);
112 return _serializer.Deserialize(payload);
113 }
114
147 public byte[] Encode(MessageEnvelope message)
148 {
149 ArgumentNullException.ThrowIfNull(message);
150 return _serializer.Serialize(message);
151 }
152}