Building a Custom Context Class

A client application creates a Context object to specify the context that it is running in. The client application includes this Context object with each request that it sends to a DCS service. The scope provider uses the information in the Context object to construct a list of scopes that match the client context, and the Discovery Services uses this list of scopes to retrieve a list of service endpoints that are compatible with the context specified by the client application. The scope ranker in the client application then orders this list of service endpoints and can use information in the Context object to determine the order of preference for these endpoints. The client application tries to contact the service by using these endpoints in this order of preference. For more information about how DCS client applications use scope and context, see DCS Context, DCS Scopes, and How a DCS Client Invokes an Operation.

The scope provider and ranker classes provided with DCS are intended to be used with the Context class, which is also provided with DCS. This Context class defines a default set of properties. You can build a custom Context class to add properties that your client applications can use to specify additional context information. You can also use a custom Context class to pass additional information that is not captured in the request messages sent by client applications.

If you build a custom Context class, you should replace the scope provider and ranker classes with custom implementations that can take advantage of the properties in your new Context class. For more information, see Building a Custom Scope Provider and Ranker.

The topics in this section describe how to implement a custom Context class and how to configure a DCS service and a client application to use it.