-
Notifications
You must be signed in to change notification settings - Fork 2
/
DocumentDbContext.cs
70 lines (58 loc) · 1.78 KB
/
DocumentDbContext.cs
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
62
63
64
65
66
67
68
69
70
using System;
using System.Configuration;
using Microsoft.Azure.Documents.Client;
namespace DocDBNotificationApi
{
/// <summary>
///
/// </summary>
public class DocumentDbContext
{
private DocumentClient _client;
/// <summary>
///
/// </summary>
public static string EndPoint = ConfigurationManager.AppSettings["EndPoint"];
/// <summary>
///
/// </summary>
public static string AuthKey = ConfigurationManager.AppSettings["AuthKey"];
/// <summary>
///
/// </summary>
public static string KeyType = ConfigurationManager.AppSettings["KeyType"];
/// <summary>
///
/// </summary>
public static string TokenVersion = ConfigurationManager.AppSettings["TokenVersion"];
/// <summary>
///
/// </summary>
public static string DatabaseId = ConfigurationManager.AppSettings["DatabaseId"];
/// <summary>
///
/// </summary>
public static string CollectionId = ConfigurationManager.AppSettings["CollectionId"];
/// <summary>
/// Create the connection
/// </summary>
public DocumentClient Client
{
get
{
if (_client != null) return _client;
var endpointUri = new Uri(EndPoint);
_client = new DocumentClient(endpointUri, AuthKey, new ConnectionPolicy
{
ConnectionMode = ConnectionMode.Direct,
ConnectionProtocol = Protocol.Tcp
});
return _client;
}
}
/// <summary>
///
/// </summary>
public static string CollectionLink { get; set; }
}
}