<PackageReference Include="BouncyCastle.Cryptography" Version="2.7.0-beta.98" />

DerSet

public class DerSet : Asn1Set
using Org.BouncyCastle.Utilities; using Org.BouncyCastle.Utilities.Collections; using System; using System.Collections.Generic; namespace Org.BouncyCastle.Asn1 { public class DerSet : Asn1Set { public static readonly DerSet Empty = new DerSet(); public static DerSet FromCollection(IReadOnlyCollection<Asn1Encodable> elements) { if (elements.Count >= 1) return new DerSet(elements); return Empty; } public static DerSet FromElement(Asn1Encodable element) { return new DerSet(element); } public static DerSet FromVector(Asn1EncodableVector elementVector) { if (elementVector.Count >= 1) return new DerSet(elementVector); return Empty; } public static DerSet Map<T>(T[] ts, Func<T, Asn1Encodable> func) { if (ts.Length >= 1) return new DerSet(CollectionUtilities.Map(ts, func)); return Empty; } public static DerSet Map<T>(IReadOnlyCollection<T> c, Func<T, Asn1Encodable> func) { if (c.Count >= 1) return new DerSet(CollectionUtilities.Map(c, func)); return Empty; } public DerSet() { } public DerSet(Asn1Encodable element) : base(element) { } public DerSet(params Asn1Encodable[] elements) : base(elements, true) { } internal DerSet(Asn1Encodable[] elements, bool doSort) : base(elements, doSort) { } public DerSet(Asn1EncodableVector elementVector) : base(elementVector, true) { } internal DerSet(Asn1EncodableVector elementVector, bool doSort) : base(elementVector, doSort) { } public DerSet(IReadOnlyCollection<Asn1Encodable> elements) : base(elements, true) { } public DerSet(Asn1Sequence sequence) : base(sequence) { } public DerSet(Asn1Set asn1Set) : base(asn1Set) { } internal DerSet(IReadOnlyCollection<Asn1Encodable> elements, bool doSort) : base(elements, doSort) { } internal DerSet(bool isSorted, Asn1Encodable[] elements) : base(isSorted, elements) { } internal override IAsn1Encoding GetEncoding(int encoding) { IAsn1Encoding[] sortedDerEncodings = GetSortedDerEncodings(); return new ConstructedDLEncoding(0, 17, sortedDerEncodings); } internal override IAsn1Encoding GetEncodingImplicit(int encoding, int tagClass, int tagNo) { IAsn1Encoding[] sortedDerEncodings = GetSortedDerEncodings(); return new ConstructedDLEncoding(tagClass, tagNo, sortedDerEncodings); } internal sealed override DerEncoding GetEncodingDer() { return new ConstructedDerEncoding(0, 17, GetSortedDerEncodings()); } internal sealed override DerEncoding GetEncodingDerImplicit(int tagClass, int tagNo) { return new ConstructedDerEncoding(tagClass, tagNo, GetSortedDerEncodings()); } private DerEncoding[] GetSortedDerEncodings() { return Objects.EnsureSingletonInitialized(ref m_sortedDerEncodings, m_elements, CreateSortedDerEncodings); } private static DerEncoding[] CreateSortedDerEncodings(Asn1Encodable[] elements) { DerEncoding[] contentsEncodingsDer = Asn1OutputStream.GetContentsEncodingsDer(elements); if (contentsEncodingsDer.Length > 1) Array.Sort(contentsEncodingsDer); return contentsEncodingsDer; } } }