/// <summary> /// ICollection method to copy collection into array /// </summary> /// <param name="array"> Array to copy to </param> /// <param name="index"> Index to start from </param> public void CopyTo(Array array, Int32 index) { if (null == array) { throw new ArgumentNullException("array"); } if ((index < array.GetLowerBound(0)) || (index > array.GetUpperBound(0))) { throw new ArgumentOutOfRangeException("index"); } // Get the names of the properties string[] nameArray = null; IWbemClassObjectFreeThreaded wbemObject = this.parent.wbemObject; object dummy = null; int flag = 0; if (isSystem) { flag |= (int)tag_WBEM_CONDITION_FLAG_TYPE.WBEM_FLAG_SYSTEM_ONLY; } else { flag |= (int)tag_WBEM_CONDITION_FLAG_TYPE.WBEM_FLAG_NONSYSTEM_ONLY; } flag |= (int)tag_WBEM_CONDITION_FLAG_TYPE.WBEM_FLAG_ALWAYS; int status = wbemObject.GetNames_(null, flag, ref dummy, out nameArray); if (status >= 0) { if ((index + nameArray.Length) > array.Length) { throw new ArgumentException("index"); } foreach (string propertyName in nameArray) { array.SetValue(new PropertyData(parent, propertyName), index++); } } if (status < 0) { if ((status & 0xfffff000) == 0x80041000) { ManagementException.ThrowWithExtendedInfo((ManagementStatus)status); } else { Marshal.ThrowExceptionForHR(status); } } return; }