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

Method WriteData

csharp/src/Fory/CollectionSerializers.cs:636–653  ·  view source on GitHub ↗
(WriteContext context, in Stack<T> value, bool hasGenerics)

Source from the content-addressed store, hash-verified

634 public override Stack<T> DefaultValue => null!;
635
636 public override void WriteData(WriteContext context, in Stack<T> value, bool hasGenerics)
637 {
638 Stack<T> safe = value ?? new Stack<T>();
639 if (safe.Count == 0)
640 {
641 CollectionCodec.WriteCollectionData(Array.Empty<T>(), context.TypeResolver.GetSerializer<T>(), context, hasGenerics);
642 return;
643 }
644
645 T[] topToBottom = safe.ToArray();
646 List<T> bottomToTop = new(topToBottom.Length);
647 for (int i = topToBottom.Length - 1; i >= 0; i--)
648 {
649 bottomToTop.Add(topToBottom[i]);
650 }
651
652 CollectionCodec.WriteCollectionData(bottomToTop, context.TypeResolver.GetSerializer<T>(), context, hasGenerics);
653 }
654
655 public override Stack<T> ReadData(ReadContext context)
656 {

Callers

nothing calls this directly

Calls 3

WriteCollectionDataMethod · 0.80
ToArrayMethod · 0.80
AddMethod · 0.45

Tested by

no test coverage detected