示例#1
0
        private object AuxillaryInvokeMethod(
            ManagementObject obj,
            BaseWMIAdapter.WMIMethodCacheEntry mdata,
            object[] arguments)
        {
            MethodInformation[] methods = new MethodInformation[1]
            {
                mdata.MethodInfoStructure
            };
            object[] newArguments;
            Adapter.GetBestMethodAndArguments(mdata.Name, methods, arguments, out newArguments);
            ParameterInformation[] parameters = mdata.MethodInfoStructure.parameters;
            Adapter.tracer.WriteLine("Parameters found {0}. Arguments supplied {0}", (object)parameters.Length, (object)newArguments.Length);
            ManagementBaseObject methodParameters = BaseWMIAdapter.CreateClassFrmObject((ManagementBaseObject)obj).GetMethodParameters(mdata.Name);

            for (int index = 0; index < parameters.Length; ++index)
            {
                BaseWMIAdapter.WMIParameterInformation parameterInformation = (BaseWMIAdapter.WMIParameterInformation)parameters[index];
                if (index < arguments.Length && arguments[index] == null)
                {
                    newArguments[index] = (object)null;
                }
                methodParameters[parameterInformation.Name] = newArguments[index];
            }
            return(this.InvokeManagementMethod(obj, mdata.Name, methodParameters));
        }
示例#2
0
 protected override T GetManagementObjectMethod <T>(ManagementBaseObject wmiObject, string methodName)
 {
     if (!typeof(T).IsAssignableFrom(typeof(PSMethod)))
     {
         return(default(T));
     }
     BaseWMIAdapter.WMIMethodCacheEntry adapterData = (BaseWMIAdapter.WMIMethodCacheEntry)BaseWMIAdapter.GetInstanceMethodTable(wmiObject, false)[methodName];
     if (adapterData == null)
     {
         return(default(T));
     }
     return(new PSMethod(adapterData.Name, this, wmiObject, adapterData) as T);
 }
示例#3
0
        private static void PopulateMethodTable(
            ManagementClass mgmtClass,
            CacheTable methodTable,
            bool staticBinding)
        {
            MethodDataCollection methods = mgmtClass.Methods;

            if (methods == null)
            {
                return;
            }
            ManagementPath classPath = mgmtClass.ClassPath;

            foreach (MethodData methodData in methods)
            {
                if (BaseWMIAdapter.IsStaticMethod(methodData) == staticBinding)
                {
                    string name = methodData.Name;
                    BaseWMIAdapter.WMIMethodCacheEntry methodCacheEntry = new BaseWMIAdapter.WMIMethodCacheEntry(name, classPath.Path, methodData);
                    methodTable.Add(name, (object)methodCacheEntry);
                }
            }
        }