コード例 #1
0
        public static void InvokeMethodSync(CimSession cimSession, string cimNamespace, string cimClassName)
        {
            try
            {
                string methodName;
                CimInstance inputInstance;
                CimMethodParametersCollection methodParameters = InvokeMethodCore(cimSession, cimNamespace, cimClassName, out methodName, out inputInstance);
                if (methodParameters == null)
                {
                    Console.WriteLine("Operation InvokeMethod not performed");
                    return;
                }

                CimMethodResult methodResult;
                if (inputInstance == null)
                {
                    methodResult = cimSession.InvokeMethod(cimNamespace, cimClassName, methodName, methodParameters);
                }
                else
                {
                    methodResult = cimSession.InvokeMethod(cimNamespace, inputInstance, methodName, methodParameters);
                }

                // Use the method result
                PrintCimMethodResult(methodResult);
            }
            catch (CimException ex)
            {
                PrintCimException(ex);
            }
            catch( Exception ex)
            {
                Console.WriteLine(ex.Message);
            }            
        }