From 819766af5799a0c6563edaa6cc000957e40c9a69 Mon Sep 17 00:00:00 2001 From: Peter Dettman Date: Mon, 24 Jul 2023 13:32:00 +0700 Subject: Refactoring in CMS stores --- crypto/src/cms/RecipientInformationStore.cs | 30 ++++++----------------------- crypto/src/cms/SignerInformationStore.cs | 21 ++++---------------- 2 files changed, 10 insertions(+), 41 deletions(-) diff --git a/crypto/src/cms/RecipientInformationStore.cs b/crypto/src/cms/RecipientInformationStore.cs index e317bc381..9b455124c 100644 --- a/crypto/src/cms/RecipientInformationStore.cs +++ b/crypto/src/cms/RecipientInformationStore.cs @@ -1,11 +1,8 @@ -using System; using System.Collections.Generic; -using Org.BouncyCastle.Utilities; - namespace Org.BouncyCastle.Cms { - public class RecipientInformationStore + public class RecipientInformationStore : IEnumerable { private readonly IList m_all; @@ -29,10 +26,7 @@ namespace Org.BouncyCastle.Cms m_all = new List(recipientInfos); } - public RecipientInformation this[RecipientID selector] - { - get { return GetFirstRecipient(selector); } - } + public RecipientInformation this[RecipientID selector] => GetFirstRecipient(selector); /** * Return the first RecipientInformation object that matches the @@ -54,20 +48,14 @@ namespace Org.BouncyCastle.Cms * * @return number of recipients identified. */ - public int Count - { - get { return m_all.Count; } - } + public int Count => m_all.Count; /** * Return all recipients in the collection * * @return a collection of recipients. */ - public IList GetRecipients() - { - return new List(m_all); - } + public IList GetRecipients() => new List(m_all); /** * Return possible empty collection with recipients matching the passed in RecipientID @@ -83,14 +71,8 @@ namespace Org.BouncyCastle.Cms return new List(list); } - System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() - { - return GetEnumerator(); - } + System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() => GetEnumerator(); - public virtual IEnumerator GetEnumerator() - { - return GetRecipients().GetEnumerator(); - } + public IEnumerator GetEnumerator() => GetRecipients().GetEnumerator(); } } diff --git a/crypto/src/cms/SignerInformationStore.cs b/crypto/src/cms/SignerInformationStore.cs index 00919c221..eb0dce6cf 100644 --- a/crypto/src/cms/SignerInformationStore.cs +++ b/crypto/src/cms/SignerInformationStore.cs @@ -1,4 +1,3 @@ -using System; using System.Collections.Generic; namespace Org.BouncyCastle.Cms @@ -64,16 +63,10 @@ namespace Org.BouncyCastle.Cms } /// The number of signers in the collection. - public int Count - { - get { return m_all.Count; } - } + public int Count => m_all.Count; /// An ICollection of all signers in the collection - public IList GetSigners() - { - return new List(m_all); - } + public IList GetSigners() => new List(m_all); /** * Return possible empty collection with signers matching the passed in SignerID @@ -89,14 +82,8 @@ namespace Org.BouncyCastle.Cms return new List(0); } - System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() - { - return GetEnumerator(); - } + System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() => GetEnumerator(); - public virtual IEnumerator GetEnumerator() - { - return GetSigners().GetEnumerator(); - } + public IEnumerator GetEnumerator() => GetSigners().GetEnumerator(); } } -- cgit 1.4.1