-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathConfig.cs
71 lines (67 loc) · 1.84 KB
/
Config.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
71
using Microsoft.Azure.Documents;
using Microsoft.Azure.Documents.Client;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace psCosmosGraph
{
class Config
{
private static Config _Instance;
private static ResourceResponse<DocumentCollection> _Graph;
private static DocumentClient _Client;
//other members...
private Config()
{ // never used
throw new Exception("WTF, who called this constructor?!?");
}
private Config(ResourceResponse<DocumentCollection> graph, DocumentClient client)
{
Config._Graph = graph;
Config._Client = client;
}
public static Config Instance
{
get
{
if (_Instance == null)
{
throw new Exception("Object not created");
}
return _Instance;
}
}
public ResourceResponse<DocumentCollection> Graph
{
get
{
if (_Instance == null)
{
throw new Exception("Object not created");
}
return _Graph;
}
}
public DocumentClient Client
{
get
{
if (_Instance == null)
{
throw new Exception("Object not created");
}
return _Client;
}
}
public static void Create(ResourceResponse<DocumentCollection> graph, DocumentClient client)
{
if (_Instance != null)
{
throw new Exception("Object already created");
}
_Instance = new Config(graph, client);
}
}
}