Skip to content

Commit cdfb1e7

Browse files
committed
added Asn1Reader.Clone() method
1 parent 8a7313d commit cdfb1e7

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

Asn1Parser/Asn1Reader.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,29 @@ public Asn1Reader GetReader() {
589589
return new Asn1Reader(GetTagRawDataAsMemory(), 0, true);
590590
}
591591
/// <summary>
592+
/// Returns a cloned instance of current object and current state.
593+
/// </summary>
594+
/// <returns>A cloned instance of <see cref="Asn1Reader"/>.</returns>
595+
public Asn1Reader Clone() {
596+
var reader = new Asn1Reader(GetRawDataAsMemory(), 0, true) {
597+
currentPosition = new AsnInternalMap(currentPosition.LevelStart, currentPosition.LevelEnd),
598+
childCount = childCount,
599+
Tag = Tag,
600+
TagName = TagName,
601+
TagLength = TagLength,
602+
PayloadStartOffset = PayloadStartOffset,
603+
PayloadLength = PayloadLength,
604+
NextSiblingOffset = NextSiblingOffset,
605+
NextOffset = NextOffset,
606+
IsConstructed = IsConstructed
607+
};
608+
foreach (KeyValuePair<Int64, AsnInternalMap> mapEntry in _offsetMap) {
609+
reader._offsetMap.Add(mapEntry.Key, mapEntry.Value);
610+
}
611+
612+
return reader;
613+
}
614+
/// <summary>
592615
/// Recursively processes ASN tree and builds internal offset map.
593616
/// </summary>
594617
/// <returns>A number of processed ASN structures.</returns>

0 commit comments

Comments
 (0)