/// <summary> /// Determines whether the element with the specified key is in the collection. /// </summary> /// <param name="valueKey">One of the values of <see cref="SmbiosStructure" /> that represents the key of the object <see cref="DmiStructure" /> to search.</param> /// <returns> /// <b>true</b> if the object <see cref="DmiStructure" /> with the <paramref name="valueKey"/> is in the collection; otherwise, it is <b>false</b>. /// </returns> /// <exception cref="InvalidEnumArgumentException"></exception> public bool Contains(DmiStructureClass valueKey) { bool knownBlockValid = SentinelHelper.IsEnumValid(valueKey, true); if (!knownBlockValid) { throw new InvalidEnumArgumentException(nameof(valueKey), (int)valueKey, typeof(DmiStructureClass)); } DmiStructure block = Items.FirstOrDefault(item => item.Class == valueKey); return(Items.Contains(block)); }
/// <summary> /// Gets the element with the specified key. /// </summary> /// <value> /// Object <see cref="DmiStructure" /> specified by its key. /// </value> /// <remarks> /// If the element does not exist, <b>null</b> is returned. /// </remarks> /// <exception cref="InvalidEnumArgumentException"></exception> public DmiStructure this[DmiStructureClass valueKey] { get { bool knownBlockValid = SentinelHelper.IsEnumValid(valueKey, true); if (!knownBlockValid) { throw new InvalidEnumArgumentException(nameof(valueKey), (int)valueKey, typeof(SmbiosStructure)); } int blockIndex = IndexOf(valueKey); if (blockIndex != -1) { return(this[blockIndex]); } return(null); } }
/// <summary> /// Returns the index of the object with the key specified in the collection /// </summary> /// <param name="ResultKey">One of the Results of <see cref="SmbiosStructure"/> that represents the key of the object to be searched in the collection.</param> /// <returns> /// Zero-base index of the first appearance of the item in the collection, if found; otherwise, -1. /// </returns> /// <exception cref="InvalidEnumArgumentException"></exception> public int IndexOf(DmiStructureClass ResultKey) { bool knownBlockValid = SentinelHelper.IsEnumValid(ResultKey, true); if (!knownBlockValid) { throw new InvalidEnumArgumentException(nameof(ResultKey), (int)ResultKey, typeof(DmiStructureClass)); } DmiStructure block = null; foreach (var item in Items) { if (item.Class != ResultKey) { continue; } block = item; break; } return(IndexOf(block)); }
/// <summary> /// Initialize a new instance of the class <see cref="DmiStructure"/>. /// </summary> /// <param name="class">Structure.</param> /// <param name="context">a <see cref="SMBIOS"/> reference.</param> internal DmiStructure(DmiStructureClass @class, SMBIOS context) { Class = @class; Context = context; }
/// <summary> /// Initialize a new instance of the class <see cref="DmiStructure" />. /// </summary> /// <param name="class">Estructura.</param> internal DmiStructure(DmiStructureClass @class) { Class = @class; }