CustomAssistantBase Class

Mercury.QTP.CustomServer Namespace : CustomAssistantBase Class
The base class for objects that enable Custom Servers in the testing tool context to run code in the AUT context.

Object Model

CustomAssistantBase Class

Remarks

CustomAssistantBase is the base class for all Record and Replay assistant classes. Assistant class objects are created and run in the AUT context. They help Custom Server objects created in testing tool context run parts of their code in the AUT context, thereby gaining direct access to the exposed methods, events, and data of the customized Control. These classes are used only in the testing tool context.

Setting up an Assistant Class



Create the Assistant class.

                    class MyRemoteAssistant : CustomAssistantBase
                {       
                        public int Add(int i, int j)
                        {
                                return(i+j);
                        }
                }
            

Create the remote object with CustomServerBase.CreateRemoteObject.

                MyRemoteAssistant oMyAssistant = 
                   (MyRemoteAssistant)CreateRemoteObject(typeof(MyRemoteAssistant));
             

Set the target control once before the first use.

             oMyAssistant.SetTargetControl(WndHandle.ToInt32());
             

Invoking Methods of an Assistant Class



Assistant class methods can be invoked directly if they can run in any thread of the AUT.

             int  i = oMyAssistant.Add(1,2);
             

Indirect invocation with CustomServerBase.InvokeAssistant causes a method to run in the Control's thread.

             int  i = (int)InvokeAssistant(oMyAssistant, "Add", 1, 2);
             

Syntax

'Declaration
 
Public Class CustomAssistantBase 
   Inherits System.MarshalByRefObject
public class CustomAssistantBase : System.MarshalByRefObject 

Inheritance Hierarchy

System.Object
   System.MarshalByRefObject
      Mercury.QTP.CustomServer.CustomAssistantBase

Protected Constructors

 NameDescription
Protected ConstructorCustomAssistantBase ConstructorDefault constructor.  
Top

Protected Properties

 NameDescription
Protected PropertyTargetControlReturns the custom control object.  
Top

Public Methods

 NameDescription
Public MethodGetInprocObjRefThis method supports the product infrastructure. Do not override it and do not invoke it directly in your code.  
Public MethodInitializeLifetimeServiceOverridden. Prevents your Custom Server from timing out. Do not change or override this implementation.  
Public MethodSetTargetControlAttaches to the target custom control object.  
Top