/
SiteExtensionInfo.cs
193 lines (170 loc) · 4.71 KB
/
SiteExtensionInfo.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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
using System;
using System.Collections.Generic;
using Kudu.Contracts.Infrastructure;
using Newtonsoft.Json;
using NuGet.Client.VisualStudio;
namespace Kudu.Contracts.SiteExtensions
{
// This is equivalent to NuGet.IPackage
public class SiteExtensionInfo : INamedObject
{
public enum SiteExtensionType
{
Gallery,
PreInstalledMonaco,
PreInstalledEnabled
}
public SiteExtensionInfo()
{
}
public SiteExtensionInfo(SiteExtensionInfo info)
{
Id = info.Id;
Title = info.Title;
Type = info.Type;
Summary = info.Summary;
Description = info.Description;
Version = info.Version;
ExtensionUrl = info.ExtensionUrl;
ProjectUrl = info.ProjectUrl;
IconUrl = info.IconUrl;
LicenseUrl = info.LicenseUrl;
Authors = info.Authors;
PublishedDateTime = info.PublishedDateTime;
IsLatestVersion = info.IsLatestVersion;
DownloadCount = info.DownloadCount;
LocalIsLatestVersion = info.LocalIsLatestVersion;
LocalPath = info.LocalPath;
InstalledDateTime = info.InstalledDateTime;
}
public SiteExtensionInfo(UIPackageMetadata data)
{
Id = data.Identity.Id;
Title = data.Title;
Type = SiteExtensionType.Gallery;
Summary = data.Summary;
Description = data.Description;
Version = data.Identity.Version.ToNormalizedString();
ProjectUrl = data.ProjectUrl == null ? null : data.ProjectUrl.ToString();
IconUrl = data.IconUrl == null ? "https://www.siteextensions.net/Content/Images/packageDefaultIcon-50x50.png" : data.IconUrl.ToString();
LicenseUrl = data.LicenseUrl == null ? null : data.LicenseUrl.ToString();
Authors = data.Authors.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
PublishedDateTime = data.Published;
IsLatestVersion = true;
DownloadCount = data.DownloadCount;
}
[JsonProperty(PropertyName = "id")]
public string Id
{
get;
set;
}
[JsonProperty(PropertyName = "title")]
public string Title
{
get;
set;
}
[JsonIgnore]
public SiteExtensionType Type
{
get;
set;
}
[JsonProperty(PropertyName = "summary")]
public string Summary
{
get;
set;
}
[JsonProperty(PropertyName = "description")]
public string Description
{
get;
set;
}
[JsonProperty(PropertyName = "version")]
public string Version
{
get;
set;
}
[JsonProperty(PropertyName = "extension_url")]
public string ExtensionUrl
{
get;
set;
}
[JsonProperty(PropertyName = "project_url")]
public string ProjectUrl
{
get;
set;
}
[JsonProperty(PropertyName = "icon_url")]
public string IconUrl
{
get;
set;
}
[JsonProperty(PropertyName = "license_url")]
public string LicenseUrl
{
get;
set;
}
[JsonProperty(PropertyName = "feed_url")]
public string FeedUrl
{
get;
set;
}
[JsonProperty(PropertyName = "authors")]
public IEnumerable<string> Authors
{
get;
set;
}
[JsonProperty(PropertyName = "published_date_time")]
public DateTimeOffset? PublishedDateTime
{
get;
set;
}
[JsonIgnore]
public bool IsLatestVersion
{
get;
set;
}
[JsonProperty(PropertyName = "download_count")]
public int DownloadCount
{
get;
set;
}
[JsonProperty(PropertyName = "local_is_latest_version")]
public bool? LocalIsLatestVersion
{
get;
set;
}
[JsonProperty(PropertyName = "local_path")]
public string LocalPath
{
get;
set;
}
[JsonProperty(PropertyName = "installed_date_time")]
public DateTimeOffset? InstalledDateTime
{
get;
set;
}
[JsonProperty(PropertyName = "name")]
public string Name
{
get { return this.Id; }
}
}
}