示例#1
0
        /// <summary>
        /// Determines whether the element with the specified key is in the <see cref="CeaDataSectionCollection"/> collection.
        /// </summary>
        /// <param name="valueKey">One of the values of <see cref="CeaSection"/> that represents the key of the object <see cref="DataSection"/> to search</param>
        /// <returns>
        /// <b>true</b> if the <see cref="DataSection"/> object with the <b>valueKey</b> is in the <see cref="CeaDataSectionCollection"/> collection; otherwise, it is <b>false</b>.
        /// </returns>
        /// <exception cref="InvalidEnumArgumentException"></exception>
        public bool Contains(CeaSection valueKey)
        {
            var knownSectionValid = IsValidSection(valueKey);

            if (!knownSectionValid)
            {
                throw new InvalidEnumArgumentException(nameof(valueKey), (int)valueKey, typeof(CeaSection));
            }

            return(ImplementedSections.Contains(valueKey));
        }
示例#2
0
        /// <summary>
        /// Search for the object with the specified key and return the zero-based index of the first occurrence in the entire <see cref="CeaDataSectionCollection"/> collection.
        /// </summary>
        /// <param name="valueKey">One of the values of <see cref="CeaSection"/> that represents the key of the object to be searched in <see cref="CeaDataSectionCollection"/></param>
        /// <returns>
        /// Zero-base index of the first occurrence of item in the whole of <see cref="CeaDataSectionCollection"/>, if found; otherwise, <b>-1</b>.
        /// </returns>
        /// <exception cref="InvalidEnumArgumentException"></exception>
        public int IndexOf(CeaSection valueKey)
        {
            var knownSectionValid = IsValidSection(valueKey);

            if (!knownSectionValid)
            {
                throw new InvalidEnumArgumentException(nameof(valueKey), (int)valueKey, typeof(CeaSection));
            }

            var section = Sections.FirstOrDefault(item => (CeaSection)item.Key == valueKey);

            return(IndexOf(section));
        }
示例#3
0
        /// <summary>
        /// Gets the section with the specified key.
        /// </summary>
        /// <value>
        /// Object <see cref="DataSection"/> specified by its key.
        /// </value>
        /// <remarks>
        /// If the element does not exist, <b>null</b> is returned.
        /// </remarks>
        /// <exception cref="InvalidEnumArgumentException"></exception>
        public DataSection this[CeaSection valueKey]
        {
            get
            {
                var knownBlockValid = IsValidSection(valueKey);
                if (!knownBlockValid)
                {
                    throw new InvalidEnumArgumentException(nameof(valueKey), (int)valueKey, typeof(CeaSection));
                }

                var sectionIndex = IndexOf(valueKey);
                if (sectionIndex != -1)
                {
                    return(this[sectionIndex]);
                }

                return(null);
            }
        }
示例#4
0
 /// <summary>
 /// Determines whether the specified key is a valid key of the <see cref="CeaSection"/> enumeration.
 /// </summary>
 /// <param name="value">Key to check</param>
 /// <returns>
 /// <b>true</b> if the value belongs to the enumeration <see cref="CeaSection"/>; otherwise, it is <b>false</b>.
 /// </returns>
 private static bool IsValidSection(CeaSection value) => SentinelHelper.IsEnumValid(value);