Now, we need to create a standard interface that will define the methods provided by the storage service. The interface will need to allow basic CRUD (create, read, update, and delete) operations. We would also like to provide basic caching capabilities. Caching can dramatically enhance app responsiveness by storing data that will likely be accessed multiple times in the memory locally and preventing multiple reads from a file or accesses to a web service.
To create the data service interface, perform the following steps:
POIApp
project in the Solution pad in Xamarin Studio.IPOIDataService
and click on OK.IReadOnlyList
. The use of IReadOnlyList
ensures that POIs cannot be added directly to the cache but must be added or deleted through the CRUD operations.The following example shows the interface's definition from the 9169_04_CodesPOIAppPOIAppIPOIDataService.cs
from the code bundle of this book. Note that in this example, SavePOI()
accounts for the create and update portion of CRUD.
public interface IPOIDataService { IReadOnlyList<PointOfInterest> POIs { get; } void RefreshCache(); PointOfInterest GetPOI (int id); void SavePOI(PointOfInterest poi); void DeletePOI(PointOfInterest poi); }
3.16.214.233