Skip to content

Commit 7c99c6f

Browse files
committed
Appx package management DTO/model WIP commit.
1 parent c39a8c3 commit 7c99c6f

7 files changed

Lines changed: 448 additions & 0 deletions

File tree

Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Collections.ObjectModel;
4+
5+
namespace PSADT.AppManagement
6+
{
7+
/// <summary>
8+
/// Represents an app package in the system.
9+
/// </summary>
10+
public sealed record AppxPackage
11+
{
12+
/// <summary>
13+
/// Initializes a new instance of the <see cref="AppxPackage"/> class.
14+
/// </summary>
15+
/// <param name="name">The display name of the app package.</param>
16+
/// <param name="publisher">The publisher of the app package.</param>
17+
/// <param name="publisherId">The publisher ID of the app package.</param>
18+
/// <param name="architecture">The architecture of the app package.</param>
19+
/// <param name="resourceId">The resource ID of the app package.</param>
20+
/// <param name="version">The version of the app package.</param>
21+
/// <param name="packageFamilyName">The package family name of the app package.</param>
22+
/// <param name="packageFullName">The full name of the app package.</param>
23+
/// <param name="installLocation">The install location of the app package.</param>
24+
/// <param name="isFramework">Indicates whether the app package is a framework.</param>
25+
/// <param name="packageUserInformation">The user information of the app package.</param>
26+
/// <param name="isResourcePackage">Indicates whether the app package is a resource package.</param>
27+
/// <param name="isBundle">Indicates whether the app package is a bundle.</param>
28+
/// <param name="isDevelopmentMode">Indicates whether the app package is in development mode.</param>
29+
/// <param name="nonRemovable">Indicates whether the app package is non-removable.</param>
30+
/// <param name="dependencies">The dependencies of the app package.</param>
31+
/// <param name="isPartiallyStaged">Indicates whether the app package is partially staged.</param>
32+
/// <param name="signatureKind">The signature kind of the app package.</param>
33+
/// <param name="status">The status of the app package.</param>
34+
public AppxPackage(string name, string publisher, string publisherId, PackageArchitecture architecture, string resourceId, Version version, string packageFamilyName, string packageFullName, string installLocation, bool isFramework, ReadOnlyCollection<PackageUserInformation> packageUserInformation, bool isResourcePackage, bool isBundle, bool isDevelopmentMode, bool nonRemovable, ReadOnlyCollection<AppxPackage> dependencies, bool isPartiallyStaged, PackageSignatureKind signatureKind, PackageStatus status)
35+
{
36+
ArgumentException.ThrowIfNullOrWhiteSpace(name);
37+
ArgumentException.ThrowIfNullOrWhiteSpace(publisher);
38+
ArgumentException.ThrowIfNullOrWhiteSpace(publisherId);
39+
ArgumentException.ThrowIfNullOrWhiteSpace(resourceId);
40+
ArgumentException.ThrowIfNullOrWhiteSpace(packageFamilyName);
41+
ArgumentException.ThrowIfNullOrWhiteSpace(packageFullName);
42+
ArgumentException.ThrowIfNullOrWhiteSpace(installLocation);
43+
DisplayName = name;
44+
Publisher = publisher;
45+
PublisherId = publisherId;
46+
Architecture = architecture;
47+
ResourceId = resourceId;
48+
Version = version;
49+
PackageFamilyName = packageFamilyName;
50+
PackageFullName = packageFullName;
51+
InstallLocation = installLocation;
52+
IsFramework = isFramework;
53+
PackageUserInformation = packageUserInformation;
54+
IsResourcePackage = isResourcePackage;
55+
IsBundle = isBundle;
56+
IsDevelopmentMode = isDevelopmentMode;
57+
NonRemovable = nonRemovable;
58+
Dependencies = dependencies;
59+
IsPartiallyStaged = isPartiallyStaged;
60+
SignatureKind = signatureKind;
61+
Status = status;
62+
}
63+
64+
/// <summary>
65+
/// Gets the name of the package.
66+
/// </summary>
67+
public string DisplayName { get; }
68+
69+
/// <summary>
70+
/// Gets the publisher of the app package.
71+
/// </summary>
72+
public string Publisher { get; }
73+
74+
/// <summary>
75+
/// Gets the publisher ID of the app package.
76+
/// </summary>
77+
public string PublisherId { get; }
78+
79+
/// <summary>
80+
/// Gets the architecture of the app package.
81+
/// </summary>
82+
public PackageArchitecture Architecture { get; }
83+
84+
/// <summary>
85+
/// Gets the resource ID of the app package.
86+
/// </summary>
87+
public string ResourceId { get; }
88+
89+
/// <summary>
90+
/// Gets the version of the app package.
91+
/// </summary>
92+
public Version Version { get; }
93+
94+
/// <summary>
95+
/// Gets the package family name of the app package.
96+
/// </summary>
97+
public string PackageFamilyName { get; }
98+
99+
/// <summary>
100+
/// Gets the full name of the app package.
101+
/// </summary>
102+
public string PackageFullName { get; }
103+
104+
/// <summary>
105+
/// Gets the install location of the app package.
106+
/// </summary>
107+
public string InstallLocation { get; }
108+
109+
/// <summary>
110+
/// Gets a value indicating whether the app package is a framework package.
111+
/// </summary>
112+
public bool IsFramework { get; }
113+
114+
/// <summary>
115+
/// Gets the user information of the app package.
116+
/// </summary>
117+
public IReadOnlyList<PackageUserInformation> PackageUserInformation { get; }
118+
119+
/// <summary>
120+
/// Gets a value indicating whether the app package is a resource package.
121+
/// </summary>
122+
public bool IsResourcePackage { get; }
123+
124+
/// <summary>
125+
/// Gets a value indicating whether the app package is a bundle package.
126+
/// </summary>
127+
public bool IsBundle { get; }
128+
129+
/// <summary>
130+
/// Gets a value indicating whether the app package is in development mode.
131+
/// </summary>
132+
public bool IsDevelopmentMode { get; }
133+
134+
/// <summary>
135+
/// Gets a value indicating whether the app package is non-removable.
136+
/// </summary>
137+
public bool NonRemovable { get; }
138+
139+
/// <summary>
140+
/// Gets the dependencies of the app package.
141+
/// </summary>
142+
public IReadOnlyList<AppxPackage> Dependencies { get; }
143+
144+
/// <summary>
145+
/// Gets a value indicating whether the app package is partially staged.
146+
/// </summary>
147+
public bool IsPartiallyStaged { get; }
148+
149+
/// <summary>
150+
/// Gets the signature kind of the app package.
151+
/// </summary>
152+
public PackageSignatureKind SignatureKind { get; }
153+
154+
/// <summary>
155+
/// Gets the status of the app package.
156+
/// </summary>
157+
public PackageStatus Status { get; }
158+
}
159+
}
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
using System;
2+
3+
namespace PSADT.AppManagement
4+
{
5+
/// <summary>
6+
/// Represents a provisioned package in the system.
7+
/// </summary>
8+
public sealed record AppxProvisionedPackage
9+
{
10+
/// <summary>
11+
/// Initializes a new instance of the <see cref="AppxProvisionedPackage"/> class.
12+
/// </summary>
13+
/// <param name="packageName">The package name of the provisioned package.</param>
14+
/// <param name="displayName">The display name of the provisioned package.</param>
15+
/// <param name="publisherId">The publisher ID of the provisioned package.</param>
16+
/// <param name="majorVersion">The major version of the provisioned package.</param>
17+
/// <param name="minorVersion">The minor version of the provisioned package.</param>
18+
/// <param name="build">The build number of the provisioned package.</param>
19+
/// <param name="revision">The revision number of the provisioned package.</param>
20+
/// <param name="architecture">The architecture of the provisioned package.</param>
21+
/// <param name="resourceId">The resource ID of the provisioned package.</param>
22+
/// <param name="installLocation">The install location of the provisioned package.</param>
23+
/// <param name="regions">The regions where the provisioned package is available.</param>
24+
public AppxProvisionedPackage(string packageName, string displayName, string publisherId, uint majorVersion, uint minorVersion, uint build, uint revision, PackageArchitecture architecture, string resourceId, string installLocation, string regions)
25+
{
26+
ArgumentException.ThrowIfNullOrWhiteSpace(packageName);
27+
ArgumentException.ThrowIfNullOrWhiteSpace(displayName);
28+
ArgumentException.ThrowIfNullOrWhiteSpace(publisherId);
29+
ArgumentException.ThrowIfNullOrWhiteSpace(resourceId);
30+
ArgumentException.ThrowIfNullOrWhiteSpace(installLocation);
31+
ArgumentException.ThrowIfNullOrWhiteSpace(regions);
32+
Version = new((int)majorVersion, (int)minorVersion, (int)build, (int)revision);
33+
PackageName = packageName;
34+
DisplayName = displayName;
35+
PublisherId = publisherId;
36+
Architecture = architecture;
37+
ResourceId = resourceId;
38+
InstallLocation = installLocation;
39+
Regions = regions;
40+
}
41+
42+
/// <summary>
43+
/// Gets the package name of the provisioned package.
44+
/// </summary>
45+
public string PackageName { get; }
46+
47+
/// <summary>
48+
/// Gets the display name of the provisioned package.
49+
/// </summary>
50+
public string DisplayName { get; }
51+
52+
/// <summary>
53+
/// Gets the publisher ID of the provisioned package.
54+
/// </summary>
55+
public string PublisherId { get; }
56+
57+
/// <summary>
58+
/// Gets the version of the provisioned package.
59+
/// </summary>
60+
public Version Version { get; }
61+
62+
/// <summary>
63+
/// Gets the architecture of the provisioned package.
64+
/// </summary>
65+
public PackageArchitecture Architecture { get; }
66+
67+
/// <summary>
68+
/// Gets the resource ID of the provisioned package.
69+
/// </summary>
70+
public string ResourceId { get; }
71+
72+
/// <summary>
73+
/// Gets the install location of the provisioned package.
74+
/// </summary>
75+
public string InstallLocation { get; }
76+
77+
/// <summary>
78+
/// Gets the regions where the provisioned package is available.
79+
/// </summary>
80+
public string Regions { get; }
81+
}
82+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
namespace PSADT.AppManagement
2+
{
3+
/// <summary>
4+
/// Specifies the processor architectures supported by a package.
5+
/// </summary>
6+
[System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1712:Do not prefix enum values with type name", Justification = "This is how it's named in the Win32 API.")]
7+
public enum PackageArchitecture
8+
{
9+
/// <summary>
10+
/// The x86 processor architecture.
11+
/// </summary>
12+
x86 = Windows.Win32.Storage.Packaging.Appx.APPX_PACKAGE_ARCHITECTURE.APPX_PACKAGE_ARCHITECTURE_X86,
13+
14+
/// <summary>
15+
/// The ARM processor architecture.
16+
/// </summary>
17+
ARM = Windows.Win32.Storage.Packaging.Appx.APPX_PACKAGE_ARCHITECTURE.APPX_PACKAGE_ARCHITECTURE_ARM,
18+
19+
/// <summary>
20+
/// The x64 processor architecture.
21+
/// </summary>
22+
x64 = Windows.Win32.Storage.Packaging.Appx.APPX_PACKAGE_ARCHITECTURE.APPX_PACKAGE_ARCHITECTURE_X64,
23+
24+
/// <summary>
25+
/// Any processor architecture.
26+
/// </summary>
27+
Neutral = Windows.Win32.Storage.Packaging.Appx.APPX_PACKAGE_ARCHITECTURE.APPX_PACKAGE_ARCHITECTURE_NEUTRAL,
28+
29+
/// <summary>
30+
/// The 64-bit ARM processor architecture.
31+
/// </summary>
32+
ARM64 = Windows.Win32.Storage.Packaging.Appx.APPX_PACKAGE_ARCHITECTURE.APPX_PACKAGE_ARCHITECTURE_ARM64,
33+
}
34+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
namespace PSADT.AppManagement
2+
{
3+
/// <summary>
4+
/// Specifies the ways that an app package may be signed.
5+
/// </summary>
6+
public enum PackageSignatureKind
7+
{
8+
/// <summary>
9+
/// Not signed.
10+
/// </summary>
11+
None = 0,
12+
13+
/// <summary>
14+
/// Deployed in your development environment. The package is signed with a private certificate.
15+
/// </summary>
16+
Developer = 1,
17+
18+
/// <summary>
19+
/// Signed using a certificate used in enterprises.
20+
/// </summary>
21+
Enterprise = 2,
22+
23+
/// <summary>
24+
/// Signed by the Windows Store.
25+
/// </summary>
26+
Store = 3,
27+
28+
/// <summary>
29+
/// Built-in system app.
30+
/// </summary>
31+
System = 4,
32+
}
33+
}
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
using System;
2+
3+
namespace PSADT.AppManagement
4+
{
5+
/// <summary>
6+
/// Provides info about the status of a Package.
7+
/// </summary>
8+
[Flags]
9+
public enum PackageStatus
10+
{
11+
/// <summary>
12+
/// The package is usable.
13+
/// </summary>
14+
Ok = 0 << 0,
15+
16+
/// <summary>
17+
/// Indicates whether there is a problem with the license for this package.
18+
/// </summary>
19+
LicenseIssue = 1 << 0,
20+
21+
/// <summary>
22+
/// Indicates whether the package is missing files, system information, etc.
23+
/// </summary>
24+
Modified = 1 << 1,
25+
26+
/// <summary>
27+
/// Indicates whether the package may have been tampered with.
28+
/// </summary>
29+
Tampered = 1 << 2,
30+
31+
/// <summary>
32+
/// Indicates whether the package has been disabled.
33+
/// </summary>
34+
Disabled = 1 << 3,
35+
36+
/// <summary>
37+
/// The package is not available for use and cannot be serviced.
38+
/// </summary>
39+
PackageOffline = 1 << 4,
40+
41+
/// <summary>
42+
/// Indicates whether the package is offline and cannot be used.
43+
/// </summary>
44+
DeploymentInProgress = 1 << 5,
45+
46+
/// <summary>
47+
/// Indicates whether this package depends on a package that can't be used.
48+
/// </summary>
49+
DependencyIssue = 1 << 6,
50+
51+
/// <summary>
52+
/// Indicates whether the data for the package is offline.
53+
/// </summary>
54+
DataOffline = 1 << 7,
55+
56+
/// <summary>
57+
/// Indicates whether the package is partially staged.
58+
/// </summary>
59+
IsPartiallyStaged = 1 << 8,
60+
61+
/// <summary>
62+
/// Indicates whether the package is available.
63+
/// </summary>
64+
NotAvailable = 1 << 9,
65+
66+
/// <summary>
67+
/// Indicates whether the package is being serviced.
68+
/// </summary>
69+
Servicing = 1 << 10,
70+
71+
/// <summary>
72+
/// Indicates whether the package is unusable.
73+
/// </summary>
74+
NeedsRemediation = 1 << 11,
75+
}
76+
}

0 commit comments

Comments
 (0)