private static object MapOutParameters(object[] args, ManagementBaseObject outParams, IWbemClassObjectFreeThreaded outParamsClass) { object item = null; int lowerBound = 0; int num = 0; if (outParamsClass != null) { if (args != null && 0 < (int)args.Length) { int upperBound = args.GetUpperBound(0); lowerBound = args.GetLowerBound(0); num = upperBound - lowerBound; } int propertyQualifierSet_ = outParamsClass.BeginEnumeration_(64); if (propertyQualifierSet_ >= 0) { do { object obj = null; int num1 = 0; string str = null; IWbemQualifierSetFreeThreaded wbemQualifierSetFreeThreaded = null; propertyQualifierSet_ = outParamsClass.Next_(0, ref str, ref obj, ref num1, ref num1); if (propertyQualifierSet_ < 0) { continue; } if (str == null) { break; } if (string.Compare(str, "RETURNVALUE", StringComparison.OrdinalIgnoreCase) != 0) { propertyQualifierSet_ = outParamsClass.GetPropertyQualifierSet_(str, out wbemQualifierSetFreeThreaded); if (propertyQualifierSet_ < 0) { continue; } try { object obj1 = 0; wbemQualifierSetFreeThreaded.Get_("ID", 0, ref obj1, ref num1); int num2 = (int)obj1; if (0 <= num2 && num >= num2) { args[lowerBound + num2] = outParams[str]; } } finally { wbemQualifierSetFreeThreaded.Dispose(); } } else { item = outParams["RETURNVALUE"]; } } while (propertyQualifierSet_ >= 0); } if (propertyQualifierSet_ < 0) { if (((long)propertyQualifierSet_ & (long)-4096) != (long)-2147217408) { Marshal.ThrowExceptionForHR(propertyQualifierSet_); } else { ManagementException.ThrowWithExtendedInfo((ManagementStatus)propertyQualifierSet_); } } } return item; }
private static object MapOutParameters( object [] args, ManagementBaseObject outParams, IWbemClassObjectFreeThreaded outParamsClass) { object result = null; int maxIndex = 0, minIndex = 0, topId = 0; int status = (int)ManagementStatus.NoError; if (null != outParamsClass) { if ((null != args) && (0 < args.Length)) { maxIndex = args.GetUpperBound(0); minIndex = args.GetLowerBound(0); topId = maxIndex - minIndex; } /* * Iterate through the [out] parameters of the class to find * the ID positional qualifier. We do this in the class because * we cannot be sure that the qualifier will be propagated to * the instance. */ status = outParamsClass.BeginEnumeration_ ((int)tag_WBEM_CONDITION_FLAG_TYPE.WBEM_FLAG_NONSYSTEM_ONLY); if (status >= 0) { while (true) { object val = null; int dummy = 0; string propertyName = null; IWbemQualifierSetFreeThreaded qualifierSet = null; status = outParamsClass.Next_(0, ref propertyName, ref val, ref dummy, ref dummy); if (status >= 0) { if (null == propertyName) break; // Handle the result parameter separately if (String.Compare(propertyName, RETURNVALUE, StringComparison.OrdinalIgnoreCase) == 0) { result = outParams[RETURNVALUE]; } else // Shouldn't get here if no args! { status = outParamsClass.GetPropertyQualifierSet_(propertyName, out qualifierSet); if (status >= 0) { try { object id = 0; qualifierSet.Get_(ID, 0, ref id, ref dummy); // Errors intentionally ignored. // If the id is in range, map the value into the args array int idIndex = (int)id; if ((0 <= idIndex) && (topId >= idIndex)) args [minIndex + idIndex] = outParams[propertyName]; } finally { // Dispose for next iteration. qualifierSet.Dispose(); } } } } if (status < 0) { break; } } } if (status < 0) { if ((status & 0xfffff000) == 0x80041000) ManagementException.ThrowWithExtendedInfo((ManagementStatus)status); else Marshal.ThrowExceptionForHR(status); } } return result; }
private static void MapInParameters(object[] args, ManagementBaseObject inParams, IWbemClassObjectFreeThreaded inParamsClass) { if (inParamsClass != null && args != null && 0 < (int)args.Length) { int upperBound = args.GetUpperBound(0); int lowerBound = args.GetLowerBound(0); int num = upperBound - lowerBound; int propertyQualifierSet_ = inParamsClass.BeginEnumeration_(64); if (propertyQualifierSet_ >= 0) { do { object obj = null; int num1 = 0; string str = null; IWbemQualifierSetFreeThreaded wbemQualifierSetFreeThreaded = null; propertyQualifierSet_ = inParamsClass.Next_(0, ref str, ref obj, ref num1, ref num1); if (propertyQualifierSet_ < 0) { continue; } if (str == null) { break; } propertyQualifierSet_ = inParamsClass.GetPropertyQualifierSet_(str, out wbemQualifierSetFreeThreaded); if (propertyQualifierSet_ < 0) { continue; } try { object obj1 = 0; wbemQualifierSetFreeThreaded.Get_("ID", 0, ref obj1, ref num1); int num2 = (int)obj1; if (0 <= num2 && num >= num2) { inParams[str] = args[lowerBound + num2]; } } finally { wbemQualifierSetFreeThreaded.Dispose(); } } while (propertyQualifierSet_ >= 0); } if (propertyQualifierSet_ < 0) { if (((long)propertyQualifierSet_ & (long)-4096) != (long)-2147217408) { Marshal.ThrowExceptionForHR(propertyQualifierSet_); } else { ManagementException.ThrowWithExtendedInfo((ManagementStatus)propertyQualifierSet_); return; } } } }
private static void MapInParameters( object [] args, ManagementBaseObject inParams, IWbemClassObjectFreeThreaded inParamsClass) { int status = (int)ManagementStatus.NoError; if (null != inParamsClass) { if ((null != args) && (0 < args.Length)) { int maxIndex = args.GetUpperBound(0); int minIndex = args.GetLowerBound(0); int topId = maxIndex - minIndex; /* * Iterate through the [in] parameters of the class to find * the ID positional qualifier. We do this in the class because * we cannot be sure that the qualifier will be propagated to * the instance. */ status = inParamsClass.BeginEnumeration_ ((int)tag_WBEM_CONDITION_FLAG_TYPE.WBEM_FLAG_NONSYSTEM_ONLY); if (status >= 0) { while (true) { object val = null; int dummy = 0; string propertyName = null; IWbemQualifierSetFreeThreaded qualifierSet = null; status = inParamsClass.Next_(0, ref propertyName, ref val, ref dummy, ref dummy); if (status >= 0) { if (null == propertyName) break; status = inParamsClass.GetPropertyQualifierSet_(propertyName, out qualifierSet); if (status >= 0) { try { object id = 0; qualifierSet.Get_(ID, 0, ref id, ref dummy); // Errors intentionally ignored. // If the id is in range, map the value into the args array int idIndex = (int)id; if ((0 <= idIndex) && (topId >= idIndex)) inParams[propertyName] = args [minIndex + idIndex]; } finally { // Dispose for next iteration. qualifierSet.Dispose(); } } } if (status < 0) { break; } } } if (status < 0) { if ((status & 0xfffff000) == 0x80041000) ManagementException.ThrowWithExtendedInfo((ManagementStatus)status); else Marshal.ThrowExceptionForHR(status); } } } }