public GetProviderMethodArgumentIndex ( string argumentName ) : int | ||
argumentName | string | |
return | int |
private void CallMethod(IInvocation invocation, UiaMethodInfoHelper methodHelper) { if (!methodHelper.SupportsDispatch) { throw new InvalidOperationException("Called method {0} doesn't support automatic metadata-driven dispatch. You have to modify schema in order to use this feature so that corresponding UiaMethodInfoHelper supports dispatch."); } var paramList = new UiaParameterListHelper(methodHelper); // 1. Fill In params to paramList from invocation arguments // we're using the fact that In params are always going before out params, so we may just go through 0..(cInParameters-1) for (int i = 0; i < methodHelper.Data.cInParameters; i++) { var desc = methodHelper.PatternMethodParamDescriptions[i]; var idx = methodHelper.GetProviderMethodArgumentIndex(desc.Name); paramList[i] = invocation.Arguments[idx]; } // 2. Call patternInstance method NativeMethods.WrapUiaComCall(() => _patternInstance.CallMethod(methodHelper.Index, paramList.Data, paramList.Count)); // 3. Fill Out params back to invocation from paramList for (int i = (int)methodHelper.Data.cInParameters; i < methodHelper.Data.cInParameters + methodHelper.Data.cOutParameters; i++) { object value = paramList[i]; var desc = methodHelper.PatternMethodParamDescriptions[i]; if (desc.Name == UiaTypesHelper.RetParamUnspeakableName) { if (invocation.Method.ReturnType == typeof(AutomationElement)) { value = AutomationElement.Wrap((IUIAutomationElement)value); } invocation.ReturnValue = value; } else { var idx = methodHelper.GetProviderMethodArgumentIndex(desc.Name); if (invocation.Method.GetParameters()[idx].ParameterType.GetElementType() == typeof(AutomationElement)) { value = AutomationElement.Wrap((IUIAutomationElement)value); } invocation.Arguments[idx] = value; } } }
private void CallMethod(IInvocation invocation, UiaMethodInfoHelper methodHelper) { if (!methodHelper.SupportsDispatch) throw new InvalidOperationException("Called method {0} doesn't support automatic metadata-driven dispatch. You have to modify schema in order to use this feature so that corresponding UiaMethodInfoHelper supports dispatch."); var paramList = new UiaParameterListHelper(methodHelper); // 1. Fill In params to paramList from invocation arguments // we're using the fact that In params are always going before out params, so we may just go through 0..(cInParameters-1) for (int i = 0; i < methodHelper.Data.cInParameters; i++) { var desc = methodHelper.PatternMethodParamDescriptions[i]; var idx = methodHelper.GetProviderMethodArgumentIndex(desc.Name); paramList[i] = invocation.Arguments[idx]; } // 2. Call patternInstance method NativeMethods.WrapUiaComCall(() => _patternInstance.CallMethod(methodHelper.Index, paramList.Data, paramList.Count)); // 3. Fill Out params back to invocation from paramList for (int i = (int)methodHelper.Data.cInParameters; i < methodHelper.Data.cInParameters + methodHelper.Data.cOutParameters; i++) { object value = paramList[i]; var desc = methodHelper.PatternMethodParamDescriptions[i]; if (desc.Name == UiaTypesHelper.RetParamUnspeakableName) { if (invocation.Method.ReturnType == typeof(AutomationElement)) value = AutomationElement.Wrap((IUIAutomationElement)value); invocation.ReturnValue = value; } else { var idx = methodHelper.GetProviderMethodArgumentIndex(desc.Name); if (invocation.Method.GetParameters()[idx].ParameterType.GetElementType() == typeof(AutomationElement)) value = AutomationElement.Wrap((IUIAutomationElement)value); invocation.Arguments[idx] = value; } } }