Skip to content
This repository has been archived by the owner on Dec 15, 2023. It is now read-only.

Services

Sweekriti Satpathy edited this page Mar 2, 2019 · 3 revisions

BaseHttpService

This class can be used to abstract away Http requests to an endpoint. The BaseHttpService base class simplifies working with REST APIs in a reliable manner by encapsulating the correct usage of HttpClient, handling common tasks such as serialization and implementing recommended cloud design patterns such as retry and circuit breaker.

Debugging

If you run into issues with the Http messages and responses being sent and received, the BaseHttpService provides a couple of callbacks that can be especially useful.

  1. HttpRequestMessageSent allows inspection of the HttpRequestMessage that is being sent from the service.
  2. HttpResponseMessageReceived allows inspection of the HttpResponseMessage received by the service. Note: this is the raw response, there is no deserialization done at this point.

An Example:

var service = new MyHttpService();

#if DEBUG
service.HttpRequestMessageSent += request => Debug.WriteLine(request);
service.HttpResponseMessageReceived += response => Debug.WriteLine(response);
#endif

Service Container

The MobCAT library includes a ServiceContainer class as a light-weight and simple mechanism for implementing the service locator IoC (Inversion of Control) design pattern. This enables both platform-specific and platform-agnostic components to be registered and subsequently resolved via a common interface within shared code. It also enables mock services to be registered for UI test or unit test purposes.

Bootstrap

The Bootstrap class centralizes the process of initializing and registering the respective services using the ServiceContainer class. Platform-specific startup actions can also be invoked using the optional Func parameter in the Begin method. The Begin method is called from the AppDelegate for iOS, and MainActivity for Android respectively.

MobCAT Framework

Beyond the MobCAT Framework

Clone this wiki locally