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)); }
protected static CacheTable GetInstanceMethodTable( ManagementBaseObject wmiObject, bool staticBinding) { lock (BaseWMIAdapter.instanceMethodCacheTable) { string str = string.Format((IFormatProvider)CultureInfo.InvariantCulture, "{0}#{1}", (object)wmiObject.ClassPath.Path, (object)staticBinding.ToString()); CacheTable methodTable = (CacheTable)BaseWMIAdapter.instanceMethodCacheTable[(object)str]; if (methodTable != null) { Adapter.tracer.WriteLine("Returning method information from internal cache", new object[0]); return(methodTable); } Adapter.tracer.WriteLine("Method information not found in internal cache. Constructing one", new object[0]); try { methodTable = new CacheTable(); if (!(wmiObject is ManagementClass mgmtClass)) { mgmtClass = BaseWMIAdapter.CreateClassFrmObject(wmiObject); } BaseWMIAdapter.PopulateMethodTable(mgmtClass, methodTable, staticBinding); BaseWMIAdapter.instanceMethodCacheTable[(object)str] = (object)methodTable; } catch (ManagementException ex) { Adapter.tracer.TraceException((Exception)ex); } catch (UnauthorizedAccessException ex) { Adapter.tracer.TraceException((Exception)ex); } return(methodTable); } }
protected override bool PropertyIsSettable(PSProperty property) { ManagementBaseObject baseObject = property.baseObject as ManagementBaseObject; try { return((bool)BaseWMIAdapter.CreateClassFrmObject(baseObject).GetPropertyQualifierValue(property.Name, "Write")); } catch (ManagementException ex) { Adapter.tracer.TraceException((Exception)ex); return(true); } catch (UnauthorizedAccessException ex) { Adapter.tracer.TraceException((Exception)ex); return(true); } }