Models/ResourceTemplate.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
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace APIManagementTemplate.Models
{
    public class ResourceTemplate
    {
        private List<string> names = new List<string>();
        public void AddName(string name)
        {
            names.Add(name);
        }
        public string GetResourceId()
        {
            return String.Join(",", names);
        }
 
        public string comments { get; set; }
        public string type { get; set; }
        public string name
        {
            get
            {
                if (string.IsNullOrEmpty(_name))
                    return "[concat(" + String.Join(",'/',", names) + ")]";
                return _name;
            }
            set
            {
                _name = value;
            }
        }
 
        private string _name = null;
 
        public string apiVersion
        {
            get
            {
                return "2017-03-01";
            }
        }
        public JObject properties { get; set; }
 
        public IList<JObject> resources { get; set; }
 
        public JArray dependsOn { get; set; }
 
        public ResourceTemplate()
        {
            properties = new JObject();
            resources = new List<JObject>();
            dependsOn = new JArray();
        }
    }
}