Dreamine.Communication.Core 1.0.2
Dreamine.Communication.Core 통신 기능과 관련 API를 제공합니다.
로딩중...
검색중...
일치하는것 없음
Dreamine.Communication.Core.Protocols.RawJsonProtocolAdapter 클래스 참조sealed

더 자세히 ...

Dreamine.Communication.Core.Protocols.RawJsonProtocolAdapter에 대한 상속 다이어그램 :
Dreamine.Communication.Core.Protocols.RawJsonProtocolAdapter에 대한 협력 다이어그램:

Public 멤버 함수

 RawJsonProtocolAdapter ()
 RawJsonProtocolAdapter (string defaultRoute, string defaultName)
 RawJsonProtocolAdapter (Encoding encoding, string defaultRoute, string defaultName)
 RawJsonProtocolAdapter (RawJsonProtocolOptions options)
MessageEnvelope Decode (byte[] payload)
byte[] Encode (MessageEnvelope message)

속성

bool NormalizePayloadToUtf8 [get]

정적 Private 멤버 함수

static ? string TryGetString (JsonElement root, string propertyName)

Private 속성

readonly Encoding _encoding
readonly string _defaultRoute
readonly string _defaultName

상세한 설명

고정 스키마가 없는 외부 JSON을 Dreamine 메시지 봉투로 감싸고 다시 송신 데이터로 변환합니다.

RawJsonProtocolAdapter.cs 파일의 16 번째 라인에서 정의되었습니다.

생성자 & 소멸자 문서화

◆ RawJsonProtocolAdapter() [1/4]

Dreamine.Communication.Core.Protocols.RawJsonProtocolAdapter.RawJsonProtocolAdapter ( )
inline

기본 원시 JSON 설정으로 어댑터를 초기화합니다.

RawJsonProtocolAdapter.cs 파일의 54 번째 라인에서 정의되었습니다.

55 : this(new RawJsonProtocolOptions())
56 {
57 }

◆ RawJsonProtocolAdapter() [2/4]

Dreamine.Communication.Core.Protocols.RawJsonProtocolAdapter.RawJsonProtocolAdapter ( string defaultRoute,
string defaultName )
inline

기본 라우트와 이름을 지정하여 어댑터를 초기화합니다.

매개변수
defaultRouteJSON에서 라우트를 찾지 못할 때 사용할 값입니다.
defaultNameJSON에서 이름을 찾지 못할 때 사용할 값입니다.
예외
ArgumentException기본 라우트 또는 이름이 비어 있는 경우 발생합니다.

RawJsonProtocolAdapter.cs 파일의 91 번째 라인에서 정의되었습니다.

92 : this(new RawJsonProtocolOptions
93 {
94 DefaultRoute = defaultRoute,
95 DefaultName = defaultName
96 })
97 {
98 }

◆ RawJsonProtocolAdapter() [3/4]

Dreamine.Communication.Core.Protocols.RawJsonProtocolAdapter.RawJsonProtocolAdapter ( Encoding encoding,
string defaultRoute,
string defaultName )
inline

외부 인코딩과 기본 메시지 메타데이터로 어댑터를 초기화합니다.

매개변수
encoding외부 JSON 송수신에 사용할 인코딩입니다.
defaultRoute라우트 추출 실패 시 사용할 값입니다.
defaultName이름 추출 실패 시 사용할 값입니다.
예외
ArgumentNullExceptionencodingnull인 경우 발생합니다.
ArgumentException기본 라우트 또는 이름이 비어 있는 경우 발생합니다.

RawJsonProtocolAdapter.cs 파일의 148 번째 라인에서 정의되었습니다.

152 : this(new RawJsonProtocolOptions
153 {
154 Encoding = encoding ?? throw new ArgumentNullException(nameof(encoding)),
155 DefaultRoute = defaultRoute,
156 DefaultName = defaultName
157 })
158 {
159 }

◆ RawJsonProtocolAdapter() [4/4]

Dreamine.Communication.Core.Protocols.RawJsonProtocolAdapter.RawJsonProtocolAdapter ( RawJsonProtocolOptions options)
inline

지정한 원시 JSON 설정으로 어댑터를 초기화합니다.

매개변수
options인코딩과 기본 메시지 메타데이터 설정입니다.
예외
ArgumentNullException설정 또는 해당 인코딩이 null인 경우 발생합니다.
ArgumentException설정의 기본 라우트 또는 이름이 비어 있는 경우 발생합니다.

RawJsonProtocolAdapter.cs 파일의 193 번째 라인에서 정의되었습니다.

194 {
195 ArgumentNullException.ThrowIfNull(options);
196 ArgumentException.ThrowIfNullOrWhiteSpace(options.DefaultRoute);
197 ArgumentException.ThrowIfNullOrWhiteSpace(options.DefaultName);
198
199 _encoding = options.Encoding ?? throw new ArgumentNullException(nameof(options.Encoding));
200 _defaultRoute = options.DefaultRoute;
201 _defaultName = options.DefaultName;
202 NormalizePayloadToUtf8 = options.NormalizePayloadToUtf8;
203 }

다음을 참조함 : _defaultName, _defaultRoute, _encoding, Dreamine.Communication.Core.Protocols.RawJsonProtocolOptions.DefaultName, Dreamine.Communication.Core.Protocols.RawJsonProtocolOptions.DefaultRoute, Dreamine.Communication.Core.Protocols.RawJsonProtocolOptions.Encoding, NormalizePayloadToUtf8, Dreamine.Communication.Core.Protocols.RawJsonProtocolOptions.NormalizePayloadToUtf8.

멤버 함수 문서화

◆ Decode()

MessageEnvelope Dreamine.Communication.Core.Protocols.RawJsonProtocolAdapter.Decode ( byte[] payload)
inline

원시 JSON을 분석하여 라우트와 이름을 가진 메시지 봉투로 변환합니다.

매개변수
payload수신한 외부 JSON 바이트입니다.
반환값
JSON 페이로드와 추출한 메타데이터를 가진 메시지입니다.
예외
ArgumentNullExceptionpayloadnull인 경우 발생합니다.
JsonException페이로드가 올바른 JSON 문서가 아닌 경우 발생합니다.

RawJsonProtocolAdapter.cs 파일의 255 번째 라인에서 정의되었습니다.

256 {
257 ArgumentNullException.ThrowIfNull(payload);
258
259 var json = _encoding.GetString(payload);
260 string route;
261 string name;
262
263 using (var document = JsonDocument.Parse(json))
264 {
265 var root = document.RootElement;
266
267 route = TryGetString(root, "route")
268 ?? TryGetString(root, "Route")
269 ?? TryGetString(root, "routingKey")
270 ?? TryGetString(root, "topic")
271 ?? TryGetString(root, "type")
272 ?? TryGetString(root, "cmd")
273 ?? _defaultRoute;
274
275 name = TryGetString(root, "name")
276 ?? TryGetString(root, "Name")
277 ?? TryGetString(root, "type")
278 ?? TryGetString(root, "cmd")
279 ?? _defaultName;
280 }
281
282 return new MessageEnvelope
283 {
284 Name = name,
285 Route = route,
286 Payload = NormalizePayloadToUtf8
287 ? Encoding.UTF8.GetBytes(json)
288 : _encoding.GetBytes(json),
289 Headers = new Dictionary<string, string>
290 {
291 ["ContentType"] = "application/json",
292 ["Protocol"] = "RawJson",
293 ["ExternalEncoding"] = _encoding.WebName
294 }
295 };
296 }

다음을 참조함 : _defaultName, _defaultRoute, _encoding, NormalizePayloadToUtf8, TryGetString().

이 함수 내부에서 호출하는 함수들에 대한 그래프입니다.:

◆ Encode()

byte[] Dreamine.Communication.Core.Protocols.RawJsonProtocolAdapter.Encode ( MessageEnvelope message)
inline

메시지 페이로드 또는 메타데이터를 외부 인코딩의 JSON 바이트로 변환합니다.

매개변수
message송신할 메시지입니다.
반환값
외부 시스템으로 송신할 JSON 바이트입니다.
예외
ArgumentNullExceptionmessagenull인 경우 발생합니다.

RawJsonProtocolAdapter.cs 파일의 330 번째 라인에서 정의되었습니다.

331 {
332 ArgumentNullException.ThrowIfNull(message);
333
334 if (message.Payload.Length > 0)
335 {
336 var json = Encoding.UTF8.GetString(message.Payload);
337 return _encoding.GetBytes(json);
338 }
339
340 var generatedJson = JsonSerializer.Serialize(new
341 {
342 name = message.Name,
343 route = message.Route
344 });
345
346 return _encoding.GetBytes(generatedJson);
347 }

다음을 참조함 : _encoding.

◆ TryGetString()

? string Dreamine.Communication.Core.Protocols.RawJsonProtocolAdapter.TryGetString ( JsonElement root,
string propertyName )
inlinestaticprivate

JSON 루트에서 지정한 속성을 찾아 문자열 표현으로 반환합니다.

매개변수
root검색할 JSON 루트 요소입니다.
propertyName찾을 속성 이름입니다.
반환값
속성의 문자열 값이며, 속성이 없으면 null입니다.

RawJsonProtocolAdapter.cs 파일의 381 번째 라인에서 정의되었습니다.

382 {
383 if (!root.TryGetProperty(propertyName, out var property))
384 {
385 return null;
386 }
387
388 return property.ValueKind == JsonValueKind.String
389 ? property.GetString()
390 : property.ToString();
391 }

다음에 의해서 참조됨 : Decode().

이 함수를 호출하는 함수들에 대한 그래프입니다.:

멤버 데이터 문서화

◆ _defaultName

readonly string Dreamine.Communication.Core.Protocols.RawJsonProtocolAdapter._defaultName
private

default Name 값을 보관합니다.

RawJsonProtocolAdapter.cs 파일의 44 번째 라인에서 정의되었습니다.

다음에 의해서 참조됨 : Decode(), RawJsonProtocolAdapter().

◆ _defaultRoute

readonly string Dreamine.Communication.Core.Protocols.RawJsonProtocolAdapter._defaultRoute
private

default Route 값을 보관합니다.

RawJsonProtocolAdapter.cs 파일의 35 번째 라인에서 정의되었습니다.

다음에 의해서 참조됨 : Decode(), RawJsonProtocolAdapter().

◆ _encoding

readonly Encoding Dreamine.Communication.Core.Protocols.RawJsonProtocolAdapter._encoding
private

encoding 값을 보관합니다.

RawJsonProtocolAdapter.cs 파일의 26 번째 라인에서 정의되었습니다.

다음에 의해서 참조됨 : Decode(), Encode(), RawJsonProtocolAdapter().

속성 문서화

◆ NormalizePayloadToUtf8

bool Dreamine.Communication.Core.Protocols.RawJsonProtocolAdapter.NormalizePayloadToUtf8
get

디코딩한 JSON 페이로드를 내부 UTF-8 형식으로 정규화할지 여부를 가져옵니다.

RawJsonProtocolAdapter.cs 파일의 213 번째 라인에서 정의되었습니다.

213{ get; }

다음에 의해서 참조됨 : Decode(), RawJsonProtocolAdapter().


이 클래스에 대한 문서화 페이지는 다음의 파일로부터 생성되었습니다.: