public static IsOutType ( UIAutomationType type ) : bool | ||
type | UIAutomationType | |
return | bool |
public void AddParameter(UiaParameterDescription param) { if (PatternMethodParamDescriptions.Count > 0 && UiaTypesHelper.IsOutType(PatternMethodParamDescriptions.Last().UiaType) && UiaTypesHelper.IsInType(param.UiaType)) { throw new ArgumentException("In param can't go after an out one. Please, ensure the correct order"); } if (ProviderMethodInfo != null && param.Name != UiaTypesHelper.RetParamUnspeakableName && !_providerMethodInfoIndicies.ContainsKey(param.Name)) { throw new ArgumentException("Provided provider's method info does not have argument with this name"); } UIAutomationType type = param.UiaType; var marshalledName = Marshal.StringToCoTaskMemUni(param.Name); if (UiaTypesHelper.IsInType(type)) { _inParamNames.Add(marshalledName); _inParamTypes.Add(type); } else { _outParamNames.Add(marshalledName); _outParamTypes.Add(type); } PatternMethodParamDescriptions.Add(param); }
public void DispatchCallToProvider(object provider, UiaParameterListHelper paramList) { if (ProviderMethodInfo == null) { throw new InvalidOperationException("You need to pass providerMethodInfo if you want to call ISchemaMember.DispatchCallToProvider"); } if (paramList.Count != PatternMethodParamDescriptions.Count) { var message = string.Format("Provided paramList has unexpected number of elements. Expected {0} but was {1}", PatternMethodParamDescriptions.Count, paramList.Count); throw new ArgumentException(message, "paramList"); } var providerCallParameters = new object[ProviderMethodInfo.GetParameters().Length]; // fill in params for (int i = 0; i < PatternMethodParamDescriptions.Count; i++) { var desc = PatternMethodParamDescriptions[i]; if (UiaTypesHelper.IsInType(desc.UiaType)) { var providerMethodParamIdx = _providerMethodInfoIndicies[desc.Name]; providerCallParameters[providerMethodParamIdx] = paramList[i]; } } // call provider object result = null; try { result = ProviderMethodInfo.Invoke(provider, providerCallParameters); } catch (TargetInvocationException e) { if (e.InnerException != null) { throw e.InnerException; } throw; } // write back out params for (int i = 0; i < PatternMethodParamDescriptions.Count; i++) { var desc = PatternMethodParamDescriptions[i]; if (desc.Name == UiaTypesHelper.RetParamUnspeakableName) { paramList[i] = result; continue; } if (UiaTypesHelper.IsOutType(desc.UiaType)) { var providerMethodParamIdx = _providerMethodInfoIndicies[desc.Name]; paramList[i] = providerCallParameters[providerMethodParamIdx]; } } }