-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAzure MobileServiceClient
More file actions
62 lines (56 loc) · 2.64 KB
/
Azure MobileServiceClient
File metadata and controls
62 lines (56 loc) · 2.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
using Microsoft.WindowsAzure.MobileServices;
using Plugin.Connectivity;
using System.Threading.Tasks;
//-------------------------------------------------------------------------//
namespace WPC_Android.AppLayer
{
//Factory class instance that initialize the connection with Azure Mobile Service
public class AzureConnectionFactory
{
//-------------------------------------------------------------------------//
// Data //
//-------------------------------------------------------------------------//
private MobileServiceClient _client;
private static AzureConnectionFactory _instance;
private const string _azureBackPoint = "YOUR_APP_BACKEND_LINK";
//-------------------------------------------------------------------------//
//-------------------------------------------------------------------------//
// Constructors //
//-------------------------------------------------------------------------//
//Inizialize the Mobile Service client
public AzureConnectionFactory()
{
_client = new MobileServiceClient(_azureBackPoint);
CurrentPlatform.Init();
}
//-------------------------------------------------------------------------//
//-------------------------------------------------------------------------//
// Main functions //
//-------------------------------------------------------------------------//
//Get the instance or create if not exist
public static AzureConnectionFactory Instance
{
get
{
if (_instance == null)
{
_instance = new AzureConnectionFactory();
}
return _instance;
}
}
//-------------------------------------------------------------------------//
public MobileServiceClient GetClient()
{
return _client;
}
//-------------------------------------------------------------------------//
//Check the internet connection to Azure back end
public async Task<bool> IsConnected()
{
return await CrossConnectivity.Current.IsRemoteReachable(_azureBackPoint, 80, 6000);
}
//-------------------------------------------------------------------------//
}
//-------------------------------------------------------------------------//
}