internal override MI_Result NativeMoveNext(MI_Operation operationHandle, out CimClass currentItem, out bool moreResults, out MI_Result operationResult, out string errorMessage, out MI_Instance errorDetailsHandle) { Debug.Assert(operationHandle != null, "Caller should verify operationHandle != null"); currentItem = null; MI_Class classHandle; MI_Result functionResult = operationHandle.GetClass( out classHandle, out moreResults, out operationResult, out errorMessage, out errorDetailsHandle); if ((classHandle != null) && !classHandle.IsNull) { if (!this.ShortenLifetimeOfResults) { classHandle = classHandle.Clone(); } currentItem = new CimClass(classHandle); } return(functionResult); }
public void SimpleGetClass() { MI_Operation operation = null; this.Session.GetClass(MI_OperationFlags.Default, MI_OperationOptions.Null, TestGetClassNamespace, TestGetClassClassName, null, out operation); MI_Class classOut; MI_Class clonedClass = null; MI_Result result; string errorMessage = null; MI_Instance errorDetails = null; bool moreResults = false; var res = operation.GetClass(out classOut, out moreResults, out result, out errorMessage, out errorDetails); MIAssert.Succeeded(res, "Expect the first GetClass call to succeed"); Assert.True(!classOut.IsNull, "Expect retrieved class instance to be non-null"); res = classOut.Clone(out clonedClass); MIAssert.Succeeded(res, "Expect the clone to succeed"); while (moreResults) { MI_Result secondaryResult = MI_Result.MI_RESULT_OK; res = operation.GetClass(out classOut, out moreResults, out secondaryResult, out errorMessage, out errorDetails); MIAssert.Succeeded(res, "Expect GetClass to succeed even if we don't want the result"); } res = operation.Close(); MIAssert.Succeeded(res, "Expect operation to close successfully"); MI_Value elementValue; UInt32 elementIndex; MI_Flags elementFlags; MI_Type elementType; bool valueExists; string referenceClass; MI_QualifierSet propertyQualifierSet; res = clonedClass.GetElement(TestGetClassPropertyName, out elementValue, out valueExists, out elementType, out referenceClass, out propertyQualifierSet, out elementFlags, out elementIndex); MIAssert.Succeeded(res, "Expect to see the normal property on the class"); Assert.Equal(MI_Type.MI_STRING, elementType, "Expect the CIM property to have the right type"); Assert.Equal(TestGetClassPropertyFlags, elementFlags, "Expect the CIM property to have the normal flags"); MI_Type miClassQualifierType; MI_Value miClassQualifierValue; MI_Flags miClassQualifierFlags; MI_QualifierSet classQualifierSet; res = clonedClass.GetClassQualifierSet(out classQualifierSet); MIAssert.Succeeded(res, "Expect to be able to get class qualifiers set"); UInt32 qualifierIndex; res = classQualifierSet.GetQualifier("UUID", out miClassQualifierType, out miClassQualifierFlags, out miClassQualifierValue, out qualifierIndex); MIAssert.Succeeded(res, "Expect to be able to get qualifier information from class"); Assert.Equal(MI_Type.MI_STRING, miClassQualifierType, "Expect qualifier type to be a string"); Assert.True((miClassQualifierFlags & MI_Flags.MI_FLAG_ENABLEOVERRIDE) != 0, "Expect flags to be standard flags"); Assert.Equal(TestGetClassUUID, miClassQualifierValue.String, "Expect UUID of class to be the known UUID"); MI_ParameterSet parameters; MI_QualifierSet methodQualifierSet; UInt32 methodIndex; res = clonedClass.GetMethod(TestGetClassMethodName, out methodQualifierSet, out parameters, out methodIndex); MIAssert.Succeeded(res, "Expect to be able to get method from class"); UInt32 parameterCount; res = parameters.GetParameterCount(out parameterCount); MIAssert.Succeeded(res, "Expect to be able to get count from parameter set"); Assert.Equal(TestGetClassParameterCount, parameterCount, "Expect there to be the documented number of parameters"); MI_Type parameterType; string parameterReferenceClass; MI_QualifierSet parameterQualifierSet; UInt32 parameterIndex; res = parameters.GetParameter(TestGetClassParameterName, out parameterType, out parameterReferenceClass, out parameterQualifierSet, out parameterIndex); MIAssert.Succeeded(res, "Expect to be able to get parameter from parameter set"); Assert.Equal(TestGetClassParameterType, parameterType, "Expect parameter type to be the documented type"); Assert.Equal(TestGetClassParameterIndex, parameterIndex, "Expect the power state to be the first parameter"); }