/// <summary>
        /// Proxy method for substitution of executing methods in adapter interface.
        /// </summary>
        /// <param name="methodCall">The IMessage containing method invoking data.</param>
        /// <returns>The IMessage containing method return data.</returns>
        protected override IMessage Invoke(IMethodCallMessage methodCall)
        {
            ReturnMessage mret = null;

            // Check if this is a method from IAdapter. Any IAdapter methods should be ignored.
            if ((methodCall.MethodBase.DeclaringType.FullName != typeof(IAdapter).FullName)
                && (methodCall.MethodBase.DeclaringType.FullName != typeof(IDisposable).FullName)
                )
            {
                TestSite.Log.Add(LogEntryKind.EnterAdapter,
                    "Interactive adapter: {0}, method: {1}",
                    ProxyType.Name,
                    methodCall.MethodName);
                try
                {
                    // Instantiate a new UI window.
                    using (InteractiveAdapterDialog adapterDlg = new InteractiveAdapterDialog(methodCall, TestSite.Properties))
                    {
                        DialogResult dialogResult = adapterDlg.ShowDialog();

                        if (dialogResult != DialogResult.OK)
                        {
                            string msg = "Failed";
                            TestSite.Assume.Fail(msg);
                        }
                        else
                        {
                            mret = new ReturnMessage(
                                adapterDlg.ReturnValue,
                                adapterDlg.OutArgs.Length > 0 ? adapterDlg.OutArgs : null,
                                adapterDlg.OutArgs.Length,
                                methodCall.LogicalCallContext,
                                methodCall);
                        }
                    }
                }
                catch (Exception ex)
                {
                    TestSite.Log.Add(LogEntryKind.Debug, ex.ToString());
                    throw;
                }
                finally
                {
                    TestSite.Log.Add(LogEntryKind.ExitAdapter,
                        "Interactive adapter: {0}, method: {1}",
                        ProxyType.Name,
                        methodCall.MethodName);
                }
            }
            else
            {
                // TODO: Do we need to take care ReturnMessage (Exception, IMethodCallMessage) ?
                mret = new ReturnMessage(null, null, 0, methodCall.LogicalCallContext, methodCall);
            }

            return mret;
        }
示例#2
0
        /// <summary>
        /// Proxy method for substitution of executing methods in adapter interface.
        /// </summary>
        /// <param name="methodCall">The IMessage containing method invoking data.</param>
        /// <returns>The IMessage containing method return data.</returns>
        protected override IMessage Invoke(IMethodCallMessage methodCall)
        {
            ReturnMessage mret = null;

            // Check if this is a method from IAdapter. Any IAdapter methods should be ignored.
            if ((methodCall.MethodBase.DeclaringType.FullName != typeof(IAdapter).FullName) &&
                (methodCall.MethodBase.DeclaringType.FullName != typeof(IDisposable).FullName)
                )
            {
                TestSite.Log.Add(LogEntryKind.EnterAdapter,
                                 "Interactive adapter: {0}, method: {1}",
                                 ProxyType.Name,
                                 methodCall.MethodName);
                try
                {
                    // Instantiate a new UI window.
                    using (InteractiveAdapterDialog adapterDlg = new InteractiveAdapterDialog(methodCall, TestSite.Properties))
                    {
                        DialogResult dialogResult = adapterDlg.ShowDialog();

                        if (dialogResult != DialogResult.OK)
                        {
                            string msg = "Failed";
                            TestSite.Assume.Fail(msg);
                        }
                        else
                        {
                            mret = new ReturnMessage(
                                adapterDlg.ReturnValue,
                                adapterDlg.OutArgs.Length > 0 ? adapterDlg.OutArgs : null,
                                adapterDlg.OutArgs.Length,
                                methodCall.LogicalCallContext,
                                methodCall);
                        }
                    }
                }
                catch (Exception ex)
                {
                    TestSite.Log.Add(LogEntryKind.Debug, ex.ToString());
                    throw;
                }
                finally
                {
                    TestSite.Log.Add(LogEntryKind.ExitAdapter,
                                     "Interactive adapter: {0}, method: {1}",
                                     ProxyType.Name,
                                     methodCall.MethodName);
                }
            }
            else
            {
                // TODO: Do we need to take care ReturnMessage (Exception, IMethodCallMessage) ?
                mret = new ReturnMessage(null, null, 0, methodCall.LogicalCallContext, methodCall);
            }

            return(mret);
        }