In a recent project, I found myself needing multiple, seemingly unrelated databases. It was crazy to copy and paste the code for such basic operations as getting all the data, etc., so the obvious alternative was a generic repository, and a database with tables for each set of data.
The first step is creating the SQLite repo. We begin by creating the class:
public class GenericSqliteRepository<T> where T : IEntity, new()
It is fairly easy to display a PDF file that is local to your phone. For example, see this article from Xamarin.com.
A bit trickier is to get a PDF from a server and then to display it. Here’s how I did it (note, this blog post offers snippets of code, rather than a complete solution… I will reduce my larger program to something manageable asap)
The first thing I did was create a model object named ReportItem. Its primary goal is to help group all the items in my list of pdf’s, but it contains the all-important URL to the pdf itself.
Next, I created a page named ShowPDFPage. In the XAML part of this page I just have a CustomWebView: