-
Notifications
You must be signed in to change notification settings - Fork 855
Expand file tree
/
Copy pathManifestModuleInfo.cs
More file actions
191 lines (165 loc) · 6.9 KB
/
ManifestModuleInfo.cs
File metadata and controls
191 lines (165 loc) · 6.9 KB
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
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using VirtoCommerce.Platform.Core.Common;
namespace VirtoCommerce.Platform.Core.Modularity
{
public class ManifestModuleInfo : ModuleInfo
{
public ManifestModuleInfo()
{
InitializationMode = InitializationMode.OnDemand;
DependsOn = new Collection<string>();
}
public ModuleIdentity Identity { get; private set; }
public string Id { get; private set; }
public SemanticVersion Version { get; private set; }
public bool Optional { get; private set; }
public string VersionTag { get; set; }
public SemanticVersion PlatformVersion { get; private set; }
public string Title { get; private set; }
public string Description { get; set; }
public IEnumerable<string> Authors { get; private set; }
public IEnumerable<string> Owners { get; private set; }
public string LicenseUrl { get; private set; }
public string ProjectUrl { get; private set; }
public string IconUrl { get; private set; }
public bool RequireLicenseAcceptance { get; private set; }
public string ReleaseNotes { get; private set; }
public string Copyright { get; private set; }
public string Tags { get; private set; }
public ICollection<ModuleIdentity> Dependencies { get; } = new List<ModuleIdentity>();
/// <summary>
/// List of incompatible modules
/// </summary>
public ICollection<ModuleIdentity> Incompatibilities { get; } = new List<ModuleIdentity>();
public bool IsRemovable { get; set; }
public bool IsInstalled { get; set; }
public ICollection<string> Groups { get; } = new List<string>();
public string FullPhysicalPath { get; set; }
public ICollection<string> Errors { get; } = new List<string>();
public bool UseFullTypeNameInSwagger { get; set; }
public ICollection<ManifestAppInfo> Apps { get; } = new List<ManifestAppInfo>();
public string StartupType { get; set; }
public virtual ManifestModuleInfo LoadFromManifest(ModuleManifest manifest)
{
if (manifest == null)
{
throw new ArgumentNullException(nameof(manifest));
}
ModuleName = manifest.Id;
if (manifest.Dependencies != null)
{
foreach (var dependency in manifest.Dependencies)
{
DependsOn.Add(dependency.Id);
}
}
Id = manifest.Id;
Version = SemanticVersion.Parse(string.Join("-", manifest.Version, manifest.VersionTag).TrimEnd('-'));
VersionTag = manifest.VersionTag;
PlatformVersion = SemanticVersion.Parse(manifest.PlatformVersion);
ReleaseNotes = manifest.ReleaseNotes;
Ref = manifest.PackageUrl;
if (manifest.Dependencies != null)
{
Dependencies.AddRange(manifest.Dependencies.Select(x => new ModuleIdentity(x.Id, SemanticVersion.Parse(x.Version), x.Optional)));
}
if (manifest.Incompatibilities != null)
{
Incompatibilities.AddRange(manifest.Incompatibilities.Select(x => new ModuleIdentity(x.Id, SemanticVersion.Parse(x.Version), x.Optional)));
}
Title = manifest.Title;
Description = manifest.Description;
Authors = manifest.Authors;
Owners = manifest.Owners;
LicenseUrl = manifest.LicenseUrl;
ProjectUrl = manifest.ProjectUrl;
IconUrl = manifest.IconUrl;
RequireLicenseAcceptance = manifest.RequireLicenseAcceptance;
Copyright = manifest.Copyright;
Tags = manifest.Tags;
Identity = new ModuleIdentity(Id, Version, Optional);
ModuleType = manifest.ModuleType;
StartupType = manifest.StartupType;
if (manifest.Groups != null)
{
Groups.AddRange(manifest.Groups);
}
if (manifest.Apps != null)
{
Apps.AddRange(manifest.Apps.Select(x => new ManifestAppInfo(x)));
}
return this;
}
public virtual ManifestModuleInfo LoadFromExternalManifest(ExternalModuleManifest manifest, ExternalModuleManifestVersion version)
{
if (manifest == null)
{
throw new ArgumentNullException(nameof(manifest));
}
ModuleName = manifest.Id;
if (version.Dependencies != null)
{
foreach (var dependency in version.Dependencies)
{
DependsOn.Add(dependency.Id);
}
}
Id = manifest.Id;
Version = version.SemanticVersion;
VersionTag = version.VersionTag;
PlatformVersion = version.PlatformSemanticVersion;
ReleaseNotes = version.ReleaseNotes;
Ref = version.PackageUrl;
if (version.Dependencies != null)
{
Dependencies.AddRange(version.Dependencies.Select(x => new ModuleIdentity(x.Id, SemanticVersion.Parse(x.Version), x.Optional)));
}
if (version.Incompatibilities != null)
{
Incompatibilities.AddRange(version.Incompatibilities.Select(x => new ModuleIdentity(x.Id, SemanticVersion.Parse(x.Version), x.Optional)));
}
Title = manifest.Title;
Description = manifest.Description;
Authors = manifest.Authors;
Owners = manifest.Owners;
LicenseUrl = manifest.LicenseUrl;
ProjectUrl = manifest.ProjectUrl;
IconUrl = manifest.IconUrl;
RequireLicenseAcceptance = manifest.RequireLicenseAcceptance;
Copyright = manifest.Copyright;
Tags = manifest.Tags;
Identity = new ModuleIdentity(Id, Version, Optional);
if (manifest.Groups != null)
{
Groups.AddRange(manifest.Groups);
}
return this;
}
public override string ToString()
{
return Identity.ToString();
}
public override bool Equals(object obj)
{
// If parameter is null return false.
if (obj == null)
{
return false;
}
// If parameter cannot be cast to ModuleIdentity return false.
if (!(obj is ManifestModuleInfo other))
{
return false;
}
// Return true if the fields match:
return (Id == other.Id) && (Version == other.Version) && (VersionTag == other.VersionTag);
}
public override int GetHashCode()
{
return ToString().GetHashCode();
}
}
}