diff options
Diffstat (limited to 'crypto/src/asn1/Asn1Set.cs')
-rw-r--r-- | crypto/src/asn1/Asn1Set.cs | 39 |
1 files changed, 11 insertions, 28 deletions
diff --git a/crypto/src/asn1/Asn1Set.cs b/crypto/src/asn1/Asn1Set.cs index f3b94121b..f9bfd21c3 100644 --- a/crypto/src/asn1/Asn1Set.cs +++ b/crypto/src/asn1/Asn1Set.cs @@ -1,20 +1,16 @@ using System; using System.Collections; +using System.Collections.Generic; using System.Diagnostics; using System.IO; -#if PORTABLE -using System.Collections.Generic; -using System.Linq; -#endif - using Org.BouncyCastle.Utilities; using Org.BouncyCastle.Utilities.Collections; namespace Org.BouncyCastle.Asn1 { public abstract class Asn1Set - : Asn1Object, IEnumerable + : Asn1Object, IEnumerable<Asn1Encodable> { internal class Meta : Asn1UniversalType { @@ -140,9 +136,15 @@ namespace Org.BouncyCastle.Asn1 this.isSorted = isSorted || elements.Length < 2; } - public virtual IEnumerator GetEnumerator() + IEnumerator IEnumerable.GetEnumerator() { - return elements.GetEnumerator(); + return GetEnumerator(); + } + + public virtual IEnumerator<Asn1Encodable> GetEnumerator() + { + IEnumerable<Asn1Encodable> e = elements; + return e.GetEnumerator(); } /** @@ -260,14 +262,6 @@ namespace Org.BouncyCastle.Asn1 if (count < 2) return elements; -#if PORTABLE - return elements - .Cast<Asn1Encodable>() - .Select(a => new { Item = a, Key = a.GetEncoded(Asn1Encodable.Der) }) - .OrderBy(t => t.Key, new DerComparer()) - .Select(t => t.Item) - .ToArray(); -#else byte[][] keys = new byte[count][]; for (int i = 0; i < count; ++i) { @@ -275,24 +269,13 @@ namespace Org.BouncyCastle.Asn1 } Array.Sort(keys, elements, new DerComparer()); return elements; -#endif } -#if PORTABLE private class DerComparer : IComparer<byte[]> { - public int Compare(byte[] x, byte[] y) - { - byte[] a = x, b = y; -#else - private class DerComparer - : IComparer - { - public int Compare(object x, object y) + public int Compare(byte[] a, byte[] b) { - byte[] a = (byte[])x, b = (byte[])y; -#endif Debug.Assert(a.Length >= 2 && b.Length >= 2); /* |