MCPcopy Create free account
hub / github.com/apache/fory / StoreTypeMeta

Method StoreTypeMeta

csharp/src/Fory/ReadContext.cs:306–357  ·  view source on GitHub ↗
(Type type, TypeMeta typeMeta)

Source from the content-addressed store, hash-verified

304 }
305
306 internal void StoreTypeMeta(Type type, TypeMeta typeMeta)
307 {
308 ulong typeKey = TypeMapKey.Get(type);
309 if (_cachedTypeMetaType == type && ReferenceEquals(_cachedTypeMeta, typeMeta))
310 {
311 return;
312 }
313
314 if (ReferenceEquals(_typeMetaType, type))
315 {
316 if (ReferenceEquals(_typeMeta, typeMeta))
317 {
318 _cachedTypeMetaType = type;
319 _cachedTypeMeta = typeMeta;
320 return;
321 }
322
323 _typeMeta = typeMeta;
324 _cachedTypeMetaType = type;
325 _cachedTypeMeta = typeMeta;
326 return;
327 }
328
329 if (_typeMetaType is null)
330 {
331 _typeMetaType = type;
332 _typeMeta = typeMeta;
333 _cachedTypeMetaType = type;
334 _cachedTypeMeta = typeMeta;
335 return;
336 }
337
338 if (_typeMetaByType is null)
339 {
340 _typeMetaByType = new UInt64Map<TypeMeta>();
341 if (_typeMeta is not null)
342 {
343 _typeMetaByType.Set(TypeMapKey.Get(_typeMetaType!), _typeMeta);
344 }
345 }
346 else if (_typeMetaByType.TryGetValue(typeKey, out TypeMeta? existing) &&
347 ReferenceEquals(existing, typeMeta))
348 {
349 _cachedTypeMetaType = type;
350 _cachedTypeMeta = typeMeta;
351 return;
352 }
353
354 _typeMetaByType.Set(typeKey, typeMeta);
355 _cachedTypeMetaType = type;
356 _cachedTypeMeta = typeMeta;
357 }
358
359 public TypeMeta? GetTypeMeta<T>()
360 {

Callers 3

ReadTypeInfoCoreMethod · 0.80
ReadRegisteredValueMethod · 0.80
ReadAnyTypeInfoMethod · 0.80

Calls 3

GetMethod · 0.45
SetMethod · 0.45
TryGetValueMethod · 0.45

Tested by

no test coverage detected