internal static ComMethodInformation[] GetMethodInformationArray(ITypeInfo typeInfo, Collection<int> methods, bool skipLastParameters) { int count = methods.Count; int num2 = 0; ComMethodInformation[] informationArray = new ComMethodInformation[count]; foreach (int num3 in methods) { IntPtr ptr; typeInfo.GetFuncDesc(num3, out ptr); System.Runtime.InteropServices.ComTypes.FUNCDESC funcdesc = (System.Runtime.InteropServices.ComTypes.FUNCDESC) Marshal.PtrToStructure(ptr, typeof(System.Runtime.InteropServices.ComTypes.FUNCDESC)); informationArray[num2++] = GetMethodInformation(funcdesc, skipLastParameters); typeInfo.ReleaseFuncDesc(ptr); } return informationArray; }
internal static ComMethodInformation[] GetMethodInformationArray(ITypeInfo typeInfo, Collection <int> methods, bool skipLastParameters) { int count = methods.Count; int num2 = 0; ComMethodInformation[] informationArray = new ComMethodInformation[count]; foreach (int num3 in methods) { IntPtr ptr; typeInfo.GetFuncDesc(num3, out ptr); System.Runtime.InteropServices.ComTypes.FUNCDESC funcdesc = (System.Runtime.InteropServices.ComTypes.FUNCDESC)Marshal.PtrToStructure(ptr, typeof(System.Runtime.InteropServices.ComTypes.FUNCDESC)); informationArray[num2++] = GetMethodInformation(funcdesc, skipLastParameters); typeInfo.ReleaseFuncDesc(ptr); } return(informationArray); }
/// <summary> /// Converts a MethodBase[] into a MethodInformation[] /// </summary> /// <returns>the ComMethodInformation[] corresponding to methods</returns> internal static ComMethodInformation[] GetMethodInformationArray(COM.ITypeInfo typeInfo, Collection <int> methods, bool skipLastParameters) { int methodCount = methods.Count; int count = 0; ComMethodInformation[] returnValue = new ComMethodInformation[methodCount]; foreach (int index in methods) { IntPtr pFuncDesc; typeInfo.GetFuncDesc(index, out pFuncDesc); COM.FUNCDESC funcdesc = ClrFacade.PtrToStructure <COM.FUNCDESC>(pFuncDesc); returnValue[count++] = ComUtil.GetMethodInformation(funcdesc, skipLastParameters); typeInfo.ReleaseFuncDesc(pFuncDesc); } return(returnValue); }
internal object InvokeMethod(PSMethod method, object[] arguments) { Type type = method.baseObject.GetType(); BindingFlags invokeAttr = BindingFlags.IgnoreCase | BindingFlags.InvokeMethod; try { object[] newArguments; ComMethodInformation methodAndArguments = (ComMethodInformation)Adapter.GetBestMethodAndArguments(this.Name, (MethodInformation[])ComUtil.GetMethodInformationArray(this.typeInfo, this.methods, false), arguments, out newArguments); object obj = type.InvokeMember(this.Name, invokeAttr, (Binder)null, method.baseObject, newArguments, ComUtil.GetModifiers(methodAndArguments.parameters), CultureInfo.CurrentCulture, (string[])null); Adapter.SetReferences(newArguments, (MethodInformation)methodAndArguments, arguments); return(methodAndArguments.ReturnType != typeof(void) ? obj : (object)AutomationNull.Value); } catch (TargetInvocationException ex) { CommandProcessorBase.CheckForSevereException(ex.InnerException); if (ex.InnerException is COMException innerException) { if (innerException.ErrorCode == -2147352573) { goto label_9; } } string str = ex.InnerException == null ? ex.Message : ex.InnerException.Message; throw new MethodInvocationException("ComMethodTargetInvocation", (Exception)ex, "ExtendedTypeSystem", "MethodInvocationException", new object[3] { (object)method.Name, (object)arguments.Length, (object)str }); } catch (COMException ex) { if (ex.ErrorCode != -2147352570) { throw new MethodInvocationException("ComMethodCOMException", (Exception)ex, "ExtendedTypeSystem", "MethodInvocationException", new object[3] { (object)method.Name, (object)arguments.Length, (object)ex.Message }); } } label_9: return((object)null); }
internal static ComMethodInformation[] GetMethodInformationArray( ITypeInfo typeInfo, Collection <int> methods, bool skipLastParameters) { int count = methods.Count; int num = 0; ComMethodInformation[] methodInformationArray = new ComMethodInformation[count]; foreach (int method in methods) { IntPtr ppFuncDesc; typeInfo.GetFuncDesc(method, out ppFuncDesc); System.Runtime.InteropServices.ComTypes.FUNCDESC structure = (System.Runtime.InteropServices.ComTypes.FUNCDESC)Marshal.PtrToStructure(ppFuncDesc, typeof(System.Runtime.InteropServices.ComTypes.FUNCDESC)); methodInformationArray[num++] = ComUtil.GetMethodInformation(structure, skipLastParameters); typeInfo.ReleaseFuncDesc(ppFuncDesc); } return(methodInformationArray); }
internal object InvokeMethod(PSMethod method, object[] arguments) { Type type = method.baseObject.GetType(); BindingFlags invokeAttr = BindingFlags.InvokeMethod | BindingFlags.IgnoreCase; try { object[] objArray; ComMethodInformation[] informationArray = ComUtil.GetMethodInformationArray(this.typeInfo, this.methods, false); ComMethodInformation methodInformation = (ComMethodInformation)Adapter.GetBestMethodAndArguments(this.Name, (MethodInformation[])informationArray, arguments, out objArray); object obj2 = type.InvokeMember(this.Name, invokeAttr, null, method.baseObject, objArray, ComUtil.GetModifiers(methodInformation.parameters), CultureInfo.CurrentCulture, null); Adapter.SetReferences(objArray, methodInformation, arguments); if (methodInformation.ReturnType != typeof(void)) { return(obj2); } return(AutomationNull.Value); } catch (TargetInvocationException exception) { CommandProcessorBase.CheckForSevereException(exception.InnerException); COMException innerException = exception.InnerException as COMException; if ((innerException == null) || (innerException.ErrorCode != -2147352573)) { string str = (exception.InnerException == null) ? exception.Message : exception.InnerException.Message; throw new MethodInvocationException("ComMethodTargetInvocation", exception, ExtendedTypeSystem.MethodInvocationException, new object[] { method.Name, arguments.Length, str }); } } catch (COMException exception3) { if (exception3.ErrorCode != -2147352570) { throw new MethodInvocationException("ComMethodCOMException", exception3, ExtendedTypeSystem.MethodInvocationException, new object[] { method.Name, arguments.Length, exception3.Message }); } } return(null); }
/// <summary> /// Converts a MethodBase[] into a MethodInformation[] /// </summary> /// <returns>the ComMethodInformation[] corresponding to methods</returns> internal static ComMethodInformation[] GetMethodInformationArray(COM.ITypeInfo typeInfo, Collection<int> methods, bool skipLastParameters) { int methodCount = methods.Count; int count = 0; ComMethodInformation[] returnValue = new ComMethodInformation[methodCount]; foreach (int index in methods) { IntPtr pFuncDesc; typeInfo.GetFuncDesc(index, out pFuncDesc); COM.FUNCDESC funcdesc = ClrFacade.PtrToStructure<COM.FUNCDESC>(pFuncDesc); returnValue[count++] = ComUtil.GetMethodInformation(funcdesc, skipLastParameters); typeInfo.ReleaseFuncDesc(pFuncDesc); } return returnValue; }