public void Remove(CryptographicAttributeObject attribute)
        {
            if (attribute == null)
            {
                throw new ArgumentNullException(nameof(attribute));
            }

            _list.Remove(attribute);
        }
        public int Add(CryptographicAttributeObject attribute)
        {
            if (attribute == null)
            {
                throw new ArgumentNullException(nameof(attribute));
            }

            //
            // Merge with existing attribute, if already existed, else add as new.
            //
            string?szOid1 = attribute.Oid.Value;

            for (int index = 0; index < _list.Count; index++)
            {
                CryptographicAttributeObject existing = _list[index];

                // To prevent caller to add the existing item into the collection again
                // Otherwise the merge will be an infinite loop
                if (object.ReferenceEquals(existing.Values, attribute.Values))
                {
                    throw new InvalidOperationException(Strings.InvalidOperation_DuplicateItemNotAllowed);
                }

                string?szOid2 = existing.Oid.Value;
                if (string.Equals(szOid1, szOid2, StringComparison.OrdinalIgnoreCase))
                {
                    //
                    // Only allow one signing time, per RFC.
                    //
                    if (string.Equals(szOid1, Oids.SigningTime, StringComparison.OrdinalIgnoreCase))
                    {
                        throw new CryptographicException(Strings.Cryptography_Pkcs9_MultipleSigningTimeNotAllowed);
                    }

                    foreach (AsnEncodedData asnEncodedData in attribute.Values)
                    {
                        existing.Values.Add(asnEncodedData);
                    }
                    return(index);
                }
            }

            int indexOfNewItem = _list.Count;

            _list.Add(attribute);
            return(indexOfNewItem);
        }
 internal void AddWithoutMerge(CryptographicAttributeObject attribute)
 {
     Debug.Assert(attribute != null);
     _list.Add(attribute);
 }
 public CryptographicAttributeObjectCollection(CryptographicAttributeObject attribute)
 {
     _list = new List <CryptographicAttributeObject>();
     _list.Add(attribute);
 }