Design the Basic Custom Server

Supported on versions 2021 R1 and earlier

For each custom control that you want to support, you develop a custom server class, that derives from the CustomServerBase class. The resulting custom server DLL runs in the context of the application and interfaces between UFT One and the custom control.

In this section, you design the CalendarSrv custom server class to support the Calendar control.

  1. Open CalendarSrv.cs. The basic framework of the class was created based on the specifications that you provided in the WPF Custom Server Setup dialog box.

    • The class inherits from CustomServerBase.

    • In the Using section, the class includes a reference to the Mercury.QTP.WPF.CustomServer namespace in the WPF Add-in Extensibility API.

      Note: If you use the UFT One Silverlight CustomServer template, the class includes a reference to the Mercury.QTP.Slv.CustomServer namespace in the Silverlight Add-in Extensibility API.

    • The class definition includes the list of interfaces it implements: IRecord, ICalendarRun, IComponentDetector, ICalendarProperties.

  2. In your project, add a reference to <WPF_Silverlight_Add-in_Extensibility_installdir>\samples\WPFExtCalendarSample\Application\WPFToolkit.dll.

    This enables you to access the methods, properties, and events of Microsoft.Windows.Controls.Calendar, by double-clicking the reference node in the Visual Studio Solution Explorer. You need to be familiar with these so that you can design code that interacts with the Calendar control.

  3. In Calendar.cs, add a using Microsoft.Windows.Controls; statement. This enables Microsoft IntelliSense for the Microsoft.Windows.Controls.Calendar control type in Visual Studio.

  4. In the CalendarSrv class, implement a common helper property that returns a reference to the custom Calendar object. You can use this throughout your custom server code to access the custom control's events, methods, and properties:

    private Calendar MyCalendar
    {
        get
        {
            return UtilityObject.ApplicationObject as Calendar; 
        }
    }
    
  5. You specified, in the WPF Custom Server Setup dialog box, that you want to customize child object handling. Therefore, a preliminary implementation of the IsKnownPartOf method in the IComponentDetector interface was created in the CalendarSrv class.

  6. Modify the IsKnownPartOf method to always return true. This means that UFT One will treat all child objects within the Calendar as part of the calendar and not as independent objects.

Continue to Implement Support for Retrieving Identification Property Values.