Share via


Creating a Basic Service Object Code Template

2/27/2008

The previous section, Setting up a Service Object Project, explained how to create an empty project to begin writing your Service Object. This section continues by adding features to that sample project. The following procedures and the sample in this topic show the steps that you must follow to create a basic Service Object template.

To create a simple class template

  1. Add using directives for the Microsoft.PointOfService and Microsoft.PointOfService.BaseServiceObjects to the top of the source file.

  2. Choose the POS for .NET Base class your Service Object will be derived from. The Base class you choose is based on the type of POS device for which you are developing this Service Object. (See POS for .NET Class Tree)

  3. If you are building your class on top of Point of Service Basic classes, also add a using directive for Microsoft.PointOfService.BasicServiceObjects.

  4. Apply a ServiceObject attribute to your Service Object class. This includes the following elements:

    • Device Type
    • Service Object name
    • Description of the Service Object
    • Major version
    • Minor version
  5. Create a default public parameterless constructor. This is required for PosExplorer to create an instance of your class by using .NET reflection.

Example

In this sample, notice the additional using directives, the ServiceObject attribute applied to the Service Object class, the Base class used for the Service Object class, and finally the public constructor without arguments.

using system; 
using Microsoft.PointOfService;
using Microsoft.PointOfService.BaseServiceObjects;

namespace Samples.ServiceObjects.SOTemplate
{
    [ServiceObject(
                DeviceType.Msr,
                "ServiceObjectTemplate",
                "Bare bones Service Object class",
                1,
                9)]
    public class MyServiceObject : MsrBase
    {
        public MyServiceObject()
        {
        }
    }
}

This sample does not compile as is. Its purpose is to demonstrate what elements are necessary for any Service Object class. However, for each POS for .NET Service Object Base class, the list of abstract methods which must be implemented is different. The following sections continue to add features to the sample until it becomes a complete, functional Service Object implementation.

See Also

Tasks

Setting up a Service Object Project
Adding Plug and Play Support

Concepts

POS for .NET Class Tree
Attributes for Identifying Service Objects and Assigning Hardware

Other Resources

Service Object Samples: Getting Started
POS for .NET Service Object Architecture