Models/DeploymentParameters.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
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System.IO;
using System.Security.Policy;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
 
namespace APIManagementTemplate.Models
{
    public class DeploymentParameters
    {
 
        [JsonProperty("$schema")]
        public string schema => Constants.deploymenParameterSchema;
 
        public string contentVersion => "1.0.0.0";
 
        public JObject parameters { get; set; }
 
 
        public DeploymentParameters()
        {
            parameters = new JObject();
        }
 
        public static DeploymentParameters FromString(string template)
        {
            return JsonConvert.DeserializeObject<DeploymentParameters>(template);
        }
 
 
        public void AddParameter(string name, object value)
        {
            JObject param = new JObject();
            param.Add("value", JToken.FromObject(value));
            parameters.Add(name, param);
        }
 
 
        public override string ToString()
        {
            return JsonConvert.SerializeObject(this);
        }
    }
}