Convert WMI CIMType to System.Type
I was working with WMI yesterday to report information about a computer. When trying to use the data in the application I ran into a problem that there is not an easy way to convert CIMTypes to System types. If anyone has a suggestion let me know. If not you can use my switch statement as a start for a Convert function.
private System.Type ConvertCimType(CimType ctValue)
{System.Type tReturnVal = null;
switch(ctValue){
case CimType.Boolean:
tReturnVal = typeof(System.Boolean) ;
break;
case CimType.Char16:
tReturnVal = typeof(System.String);
break;
case CimType.DateTime:
tReturnVal = typeof(System.DateTime);
break;
case CimType.Object:
tReturnVal = typeof(System.Object);
break;
case CimType.Real32:
tReturnVal = typeof(System.Decimal);
break;
case CimType.Real64:
tReturnVal = typeof(System.Decimal);
break;
case CimType.Reference:
tReturnVal = typeof(System.Object);
break;
case CimType.SInt16:
tReturnVal = typeof(System.Int16);
break;
case CimType.SInt32:
tReturnVal = typeof(System.Int32);
break;
case CimType.SInt8:
tReturnVal = typeof(System.Int16);
break;
case CimType.String:
tReturnVal = typeof(System.String);
break;
case CimType.UInt16:
tReturnVal = typeof(System.UInt16);
break;
case CimType.UInt32:
tReturnVal = typeof(System.UInt32);
break;
case CimType.UInt64:
tReturnVal = typeof(System.UInt64);
break;
case CimType.UInt8:
tReturnVal = typeof(System.UInt16);
break;
}
return tReturnVal;
}
—Brendon Schwartz