Helper class to assemble information about a custom method Corresponds to UIAutomationMethodInfo.
Inheritance: ISchemaMember
        // Call a pattern instance method with only in-params
        protected void CallMethod(UiaMethodInfoHelper methodInfo, params object[] methodParams)
        {
            // Create and init a parameter list
            var paramList = new UiaParameterListHelper(methodInfo);
            paramList.Initialize(methodParams);

            // Call through
            PatternInstance.CallMethod(methodInfo.Index, paramList.Data, paramList.Count);
        }
        // Call a pattern instance method with only in-params
        protected void CallMethod(UiaMethodInfoHelper methodInfo, params object[] methodParams)
        {
            // Create and init a parameter list
            var paramList = new UiaParameterListHelper(methodInfo);

            paramList.Initialize(methodParams);

            // Call through
            PatternInstance.CallMethod(methodInfo.Index, paramList.Data, paramList.Count);
        }
 // Construct a parameter list from a method info structure
 public UiaParameterListHelper(UiaMethodInfoHelper methodInfo)
 {
     foreach (var inParamType in methodInfo.InParamTypes)
     {
         _uiaParams.Add(new UiaParameterHelper(inParamType));
     }
     foreach (var outParamType in methodInfo.OutParamTypes)
     {
         _uiaParams.Add(new UiaParameterHelper(outParamType));
     }
 }
 // Construct a parameter list from a method info structure
 public UiaParameterListHelper(UiaMethodInfoHelper methodInfo)
 {
     foreach (var inParamType in methodInfo.InParamTypes)
     {
         _uiaParams.Add(new UiaParameterHelper(inParamType));
     }
     foreach (var outParamType in methodInfo.OutParamTypes)
     {
         _uiaParams.Add(new UiaParameterHelper(outParamType));
     }
 }
        // Get a current property value by calling a method, rather than by using GetProperty
        protected object GetCurrentPropertyValueViaMethod(UiaMethodInfoHelper methodInfo)
        {
            // Create and init a parameter list
            var paramList = new UiaParameterListHelper(methodInfo);
            Debug.Assert(paramList.Count == 1);

            // Call through
            PatternInstance.CallMethod(methodInfo.Index, paramList.Data, paramList.Count);

            // Return the out-parameter
            return paramList[0];
        }
        // Get a current property value by calling a method, rather than by using GetProperty
        protected object GetCurrentPropertyValueViaMethod(UiaMethodInfoHelper methodInfo)
        {
            // Create and init a parameter list
            var paramList = new UiaParameterListHelper(methodInfo);

            Debug.Assert(paramList.Count == 1);

            // Call through
            PatternInstance.CallMethod(methodInfo.Index, paramList.Data, paramList.Count);

            // Return the out-parameter
            return(paramList[0]);
        }
        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;
                }
            }
        }
 // Call a pattern instance method with this parameter list
 protected void CallMethod(UiaMethodInfoHelper methodInfo, UiaParameterListHelper paramList)
 {
     PatternInstance.CallMethod(methodInfo.Index, paramList.Data, paramList.Count);
 }
 /// <summary>
 /// Add a method to this pattern
 /// </summary>
 /// <param name="method"></param>
 public void AddMethod(UiaMethodInfoHelper method)
 {
     _methods.Add(method);
 }
 // Call a pattern instance method with this parameter list
 protected void CallMethod(UiaMethodInfoHelper methodInfo, UiaParameterListHelper paramList)
 {
     PatternInstance.CallMethod(methodInfo.Index, paramList.Data, paramList.Count);
 }
 /// <summary>
 /// Add a method to this pattern
 /// </summary>
 /// <param name="method"></param>
 public void AddMethod(UiaMethodInfoHelper method)
 {
     _methods.Add(method);
 }