/// <summary> /// Checks the type of the <paramref name="serializerConfig"/> to ensure it can be operated on by this class (it has to be a <see cref="ConfigurationElement"/>). /// </summary> /// <param name="serializerConfig">The element to check to ensure that it is a <see cref="ConfigurationElement"/>.</param> // ReSharper disable once UnusedParameter.Local private void CheckType(ISerializerConfig serializerConfig) { if (!(serializerConfig is ConfigurationElement)) { throw new NapConfigurationException("Header element being acted on by ISerializersConfig must inherit ConfigurationElement."); } }
/// <summary> /// Removes the first occurrence of a specific object from the <see cref="T:System.Collections.Generic.ICollection`1"/>. /// Removes elements from the base <see cref="ConfigurationElementCollection"/> class. /// </summary> /// <returns> /// true if <paramref name="item"/> was successfully removed from the <see cref="T:System.Collections.Generic.ICollection`1"/>; otherwise, false. This method also returns false if <paramref name="item"/> is not found in the original <see cref="T:System.Collections.Generic.ICollection`1"/>. /// </returns> /// <param name="item">The object to remove from the <see cref="T:System.Collections.Generic.ICollection`1"/>.</param><exception cref="T:System.NotSupportedException">The <see cref="T:System.Collections.Generic.ICollection`1"/> is read-only.</exception> public bool Remove(ISerializerConfig item) { CheckType(item); var index = BaseIndexOf((ConfigurationElement)item); if (index >= 0) { BaseRemoveAt(index); } return(index >= 0); }
/// <summary> /// Determines whether the <see cref="T:System.Collections.Generic.ICollection`1"/> contains a specific value. /// Checks the base <see cref="ConfigurationElementCollection"/> class to see if the element is present. /// </summary> /// <returns> /// true if <paramref name="item"/> is found in the <see cref="T:System.Collections.Generic.ICollection`1"/>; otherwise, false. /// </returns> /// <param name="item">The object to locate in the <see cref="T:System.Collections.Generic.ICollection`1"/>.</param> public bool Contains(ISerializerConfig item) { CheckType(item); var itemFound = false; var enumerator = GetEnumerator(); while (enumerator.MoveNext()) { itemFound = itemFound || enumerator.Current == item; } return(itemFound); }
/// <summary> /// Adds an item to the <see cref="T:System.Collections.Generic.ICollection`1"/>. /// Adds the element to the base <see cref="ConfigurationElementCollection"/> class. /// </summary> /// <param name="item">The object to add to the <see cref="T:System.Collections.Generic.ICollection`1"/>.</param><exception cref="T:System.NotSupportedException">The <see cref="T:System.Collections.Generic.ICollection`1"/> is read-only.</exception> public void Add(ISerializerConfig item) { CheckType(item); BaseAdd((ConfigurationElement)item); }