public PgpSecretKeyRingBundle(global::System.Collections.IEnumerable e) { secretRings = Platform.CreateHashtable(); order = Platform.CreateArrayList(); global::System.Collections.IEnumerator enumerator = e.GetEnumerator(); try { while (enumerator.MoveNext()) { object current = enumerator.get_Current(); PgpSecretKeyRing pgpSecretKeyRing = current as PgpSecretKeyRing; if (pgpSecretKeyRing == null) { throw new PgpException(Platform.GetTypeName(current) + " found where PgpSecretKeyRing expected"); } long keyId = pgpSecretKeyRing.GetPublicKey().KeyId; secretRings.Add((object)keyId, (object)pgpSecretKeyRing); order.Add((object)keyId); } } finally { global::System.IDisposable disposable = enumerator as global::System.IDisposable; if (disposable != null) { disposable.Dispose(); } } }
public static PgpSecretKeyRingBundle RemoveSecretKeyRing(PgpSecretKeyRingBundle bundle, PgpSecretKeyRing secretKeyRing) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) long keyId = secretKeyRing.GetPublicKey().KeyId; if (!bundle.secretRings.Contains((object)keyId)) { throw new ArgumentException("Collection does not contain a key with a keyId for the passed in ring."); } IDictionary val = Platform.CreateHashtable(bundle.secretRings); global::System.Collections.IList list = Platform.CreateArrayList((global::System.Collections.ICollection)bundle.order); val.Remove((object)keyId); list.Remove((object)keyId); return(new PgpSecretKeyRingBundle(val, list)); }
/// <summary> /// Return a new bundle containing the contents of the passed in bundle with /// the passed in secret key ring removed. /// </summary> /// <param name="bundle">The <c>PgpSecretKeyRingBundle</c> the key ring is to be removed from.</param> /// <param name="secretKeyRing">The key ring to be removed.</param> /// <returns>A new <c>PgpSecretKeyRingBundle</c> not containing the passed in key ring.</returns> /// <exception cref="ArgumentException">If the keyId for the passed in key ring is not present.</exception> public static PgpSecretKeyRingBundle RemoveSecretKeyRing(PgpSecretKeyRingBundle bundle, PgpSecretKeyRing secretKeyRing) { var key = secretKeyRing.GetPublicKey().KeyId; if (!bundle._secretRings.Contains(key)) { throw new ArgumentException("Collection does not contain a key with a keyId for the passed in ring."); } var newSecretRings = Platform.CreateHashtable(bundle._secretRings); var newOrder = Platform.CreateArrayList(bundle._order); newSecretRings.Remove(key); newOrder.Remove(key); return(new PgpSecretKeyRingBundle(newSecretRings, newOrder)); }
/// <summary> /// Return a new bundle containing the contents of the passed in bundle with /// the passed in secret key ring removed. /// </summary> /// <param name="bundle">The <c>PgpSecretKeyRingBundle</c> the key ring is to be removed from.</param> /// <param name="secretKeyRing">The key ring to be removed.</param> /// <returns>A new <c>PgpSecretKeyRingBundle</c> not containing the passed in key ring.</returns> /// <exception cref="ArgumentException">If the keyId for the passed in key ring is not present.</exception> public static PgpSecretKeyRingBundle RemoveSecretKeyRing( PgpSecretKeyRingBundle bundle, PgpSecretKeyRing secretKeyRing) { long key = secretKeyRing.GetPublicKey().KeyId; if (!bundle.secretRings.Contains(key)) { throw new ArgumentException("Collection does not contain a key with a keyId for the passed in ring."); } IDictionary newSecretRings = new Hashtable(bundle.secretRings); ArrayList newOrder = new ArrayList(bundle.order); newSecretRings.Remove(key); newOrder.Remove(key); return(new PgpSecretKeyRingBundle(newSecretRings, newOrder)); }
/// <summary> /// Return a new bundle containing the contents of the passed in bundle and /// the passed in secret key ring. /// </summary> /// <param name="bundle">The <c>PgpSecretKeyRingBundle</c> the key ring is to be added to.</param> /// <param name="secretKeyRing">The key ring to be added.</param> /// <returns>A new <c>PgpSecretKeyRingBundle</c> merging the current one with the passed in key ring.</returns> /// <exception cref="ArgumentException">If the keyId for the passed in key ring is already present.</exception> public static PgpSecretKeyRingBundle AddSecretKeyRing( PgpSecretKeyRingBundle bundle, PgpSecretKeyRing secretKeyRing) { long key = secretKeyRing.GetPublicKey().KeyId; if (bundle.secretRings.Contains(key)) { throw new ArgumentException("Collection already contains a key with a keyId for the passed in ring."); } IDictionary newSecretRings = Platform.CreateHashtable(bundle.secretRings); IList newOrder = Platform.CreateArrayList(bundle.order); newSecretRings[key] = secretKeyRing; newOrder.Add(key); return(new PgpSecretKeyRingBundle(newSecretRings, newOrder)); }
public PgpSecretKeyRingBundle( IEnumerable e) { this.secretRings = new Hashtable(); this.order = new ArrayList(); foreach (object obj in e) { PgpSecretKeyRing pgpSecret = obj as PgpSecretKeyRing; if (pgpSecret == null) { throw new PgpException(obj.GetType().FullName + " found where PgpSecretKeyRing expected"); } long key = pgpSecret.GetPublicKey().KeyId; secretRings.Add(key, pgpSecret); order.Add(key); } }
/// <summary> /// Return a new bundle containing the contents of the passed in bundle and /// the passed in secret key ring. /// </summary> /// <param name="bundle">The <c>PgpSecretKeyRingBundle</c> the key ring is to be added to.</param> /// <param name="secretKeyRing">The key ring to be added.</param> /// <returns>A new <c>PgpSecretKeyRingBundle</c> merging the current one with the passed in key ring.</returns> /// <exception cref="ArgumentException">If the keyId for the passed in key ring is already present.</exception> public static PgpSecretKeyRingBundle AddSecretKeyRing( PgpSecretKeyRingBundle bundle, PgpSecretKeyRing secretKeyRing) { long key = secretKeyRing.GetPublicKey().KeyId; if (bundle.secretRings.Contains(key)) { throw new ArgumentException("Collection already contains a key with a keyId for the passed in ring."); } IDictionary newSecretRings = new Hashtable(bundle.secretRings); ArrayList newOrder = new ArrayList(bundle.order); newSecretRings[key] = secretKeyRing; newOrder.Add(key); return new PgpSecretKeyRingBundle(newSecretRings, newOrder); }
/// <summary> /// Return a new bundle containing the contents of the passed in bundle with /// the passed in secret key ring removed. /// </summary> /// <param name="bundle">The <c>PgpSecretKeyRingBundle</c> the key ring is to be removed from.</param> /// <param name="secretKeyRing">The key ring to be removed.</param> /// <returns>A new <c>PgpSecretKeyRingBundle</c> not containing the passed in key ring.</returns> /// <exception cref="ArgumentException">If the keyId for the passed in key ring is not present.</exception> public static PgpSecretKeyRingBundle RemoveSecretKeyRing( PgpSecretKeyRingBundle bundle, PgpSecretKeyRing secretKeyRing) { long key = secretKeyRing.GetPublicKey().KeyId; if (!bundle.secretRings.Contains(key)) { throw new ArgumentException("Collection does not contain a key with a keyId for the passed in ring."); } IDictionary newSecretRings = Platform.CreateHashtable(bundle.secretRings); IList newOrder = Platform.CreateArrayList(bundle.order); newSecretRings.Remove(key); newOrder.Remove(key); return new PgpSecretKeyRingBundle(newSecretRings, newOrder); }
/// <summary> /// Return a new bundle containing the contents of the passed in bundle and /// the passed in secret key ring. /// </summary> /// <param name="bundle">The <c>PgpSecretKeyRingBundle</c> the key ring is to be added to.</param> /// <param name="secretKeyRing">The key ring to be added.</param> /// <returns>A new <c>PgpSecretKeyRingBundle</c> merging the current one with the passed in key ring.</returns> /// <exception cref="ArgumentException">If the keyId for the passed in key ring is already present.</exception> public static PgpSecretKeyRingBundle AddSecretKeyRing(PgpSecretKeyRingBundle bundle, PgpSecretKeyRing secretKeyRing) { var key = secretKeyRing.GetPublicKey().KeyId; if (bundle._secretRings.Contains(key)) { throw new ArgumentException("Collection already contains a key with a keyId for the passed in ring."); } var newSecretRings = Platform.CreateHashtable(bundle._secretRings); var newOrder = Platform.CreateArrayList(bundle._order); newSecretRings[key] = secretKeyRing; newOrder.Add(key); return new PgpSecretKeyRingBundle(newSecretRings, newOrder); }