forked from Azure/cognitive-services
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Configuration.cs
102 lines (88 loc) · 4.08 KB
/
Configuration.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
//
// Copyright Microsoft Corporation ("Microsoft").
//
// Microsoft grants you the right to use this software in accordance with your subscription agreement, if any, to use software
// provided for use with Microsoft Azure ("Subscription Agreement"). All software is licensed, not sold.
//
// If you do not have a Subscription Agreement, or at your option if you so choose, Microsoft grants you a nonexclusive, perpetual,
// royalty-free right to use and modify this software solely for your internal business purposes in connection with Microsoft Azure
// and other Microsoft products, including but not limited to, Microsoft R Open, Microsoft R Server, and Microsoft SQL Server.
//
// Unless otherwise stated in your Subscription Agreement, the following applies. THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT
// WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL MICROSOFT OR ITS LICENSORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
// TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THE SAMPLE CODE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
namespace RssGenerator
{
/// <summary>
/// Sub item in the Configuration.json that identifies the
/// RSS feeds and storage container.
/// </summary>
class RssFeedInfo
{
[JsonProperty(PropertyName = "storage_container")]
public String AzureStorageContainer { get; set; }
[JsonProperty(PropertyName = "feed")]
public String RSSFeed { get; set; }
}
/// <summary>
/// Class that wraps the Configuration.json file that is used to drive
/// the functionality.
/// </summary>
class Configuration
{
[JsonIgnore]
private const string FILE = "Configuration.json";
/// <summary>
/// URI of the CosmosDB
/// </summary>
[JsonProperty(PropertyName = "cosmos_db_uri")]
public String CosmosUri { get; set; }
/// <summary>
/// Key to the CosmosDB
/// </summary>
[JsonProperty(PropertyName = "cosmos_db_key")]
public String CosmosKey { get; set; }
/// <summary>
/// Cosmos Database To Use
/// </summary>
[JsonProperty(PropertyName = "cosmos_db_database")]
public String CosmosDatabase { get; set; }
/// <summary>
/// Azure Storage Account connection string to put image attachments
/// </summary>
[JsonProperty(PropertyName = "azure_storage_connection")]
public String StorageConnectionString { get; set; }
/// <summary>
/// CosmosDB Collection to use for ingest. This will be the one
/// that has the ingest trigger associated with it.
/// </summary>
[JsonProperty(PropertyName = "cosmos_db_ingest_collection")]
public String CosmosIngestCollection { get; set; }
[JsonProperty(PropertyName = "cosmos_db_collections")]
public List<String> CosmosCollectionList { get; set; }
/// <summary>
/// The RSS feeds to read and insert.
/// </summary>
[JsonProperty(PropertyName = "rss_feeds")]
public List<RssFeedInfo> Feeds { get; set; }
protected Configuration()
{
this.Feeds = new List<RssFeedInfo>();
this.CosmosCollectionList = new List<string>();
}
public static Configuration GetConfiguration()
{
String path = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, Configuration.FILE);
return JsonConvert.DeserializeObject<Configuration>(System.IO.File.ReadAllText(path));
}
}
}