//****************************************************** //GetText //****************************************************** /// <summary> /// <para>Returns a textual representation of the object in the specified format.</para> /// </summary> /// <param name='format'>Specifies the requested textual format </param> /// <returns> /// The textual representation of the /// object in the specified format. /// </returns> /// <remarks> /// Currently the only format that WMI supports /// is MOF (Managed Object Format). However, in the future different other formats /// will be plugged in, such as XML. /// </remarks> // TODO: What's the relationship to ISerializable if any ? public string GetText(TextFormat format) { Initialize(); switch (format) { case TextFormat.Mof: string objText = null; int status = (int)ManagementStatus.NoError; status = wbemObject.GetObjectText_(0, out objText); if (status < 0) { if ((status & 0xfffff000) == 0x80041000) { ManagementException.ThrowWithExtendedInfo((ManagementStatus)status); } else { Marshal.ThrowExceptionForHR(status); } } return(objText); default: // TODO - integrate support for XML formats if we // can rely on Whistler IWbemObjectTextSrc return(null); } }