public void Dispatch(object pTarget, uint index, UIAutomationParameter[] pParams, uint cParams)
        {
            // Parse the provider and parameter list
            var provider = (ITestProvider) pTarget;
            var paramList = new UiaParameterListHelper(pParams);

            var member = TestSchema.GetInstance().GetMemberByIndex(index);
            if (member != null)
            {
                member.DispatchCallToProvider(provider, paramList);
                return;
            }

            // Dispatch the method/property calls
            if (index == TestSchema.GetInstance().GetBoolValueMethod.Index)
            {
                paramList[0] = provider.BoolValue;
            }
            else if (index == TestSchema.GetInstance().GetDoubleValueMethod.Index)
            {
                paramList[0] = provider.DoubleValue;
            }
            else if (index == TestSchema.GetInstance().GetElementValueMethod.Index)
            {
                paramList[0] = provider.ElementValue;
            }
            else
            {
                throw new InvalidOperationException();
            }
        }
 // Construct a parameter list from a given in-memory structure
 public UiaParameterListHelper(UIAutomationParameter[] pParams)
 {
     // Construct the parameter list from the marshalled data
     for (uint i = 0; i < pParams.Length; ++i)
     {
         _uiaParams.Add(new UiaParameterHelper(pParams[i].type, pParams[i].pData));
     }
 }
        public void Dispatch(object pTarget, uint index, UIAutomationParameter[] pParams, uint cParams)
        {
            ISchemaMember dispatchingMember = _schema.GetMemberByIndex(index);
            if (dispatchingMember == null)
                throw new NotSupportedException("Dispatching of this method is not supported");

            dispatchingMember.DispatchCallToProvider(pTarget, new UiaParameterListHelper(pParams));
        }
        public void PatternHandler_VoidParameterlessMethodCalled_DispatchedCorrectly()
        {
            var schema = new AttributeDrivenPatternSchema(typeof(IAttrDrivenTestProvider), typeof(IAttrDrivenTestPattern));

            schema.Register();

            var pParams = new UIAutomationParameter[0];

            var p = Substitute.For <IAttrDrivenTestProvider>();

            schema.Handler.Dispatch(p, schema.Methods[0].Index, pParams, 0);
            p.Received().VoidParameterlessMethod();
        }
        public void Dispatch(object pTarget, uint index, UIAutomationParameter[] pParams, uint cParams)
        {
            // Parse the provider and parameter list
            var provider = (IColorProvider) pTarget;
            var paramList = new UiaParameterListHelper(pParams);

            // Dispatch the method/property calls
            if (index == ColorSchema.GetInstance().ValueAsColorProperty.Index)
            {
                paramList[0] = provider.ValueAsColor;
            }
            else if (index == ColorSchema.GetInstance().SetValueAsColorMethod.Index)
            {
                provider.SetValueAsColor((int) paramList[0]);
            }
            else
            {
                throw new InvalidOperationException();
            }
        }