Skip to content

Commit cba80c5

Browse files
committed
Start modelling the data for AppxPackage (installed).
1 parent 42256ae commit cba80c5

5 files changed

Lines changed: 332 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: 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+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
using System;
2+
3+
namespace PSADT.AppManagement
4+
{
5+
/// <summary>
6+
/// Represents the user information of an app package.
7+
/// </summary>
8+
public sealed record PackageUserInformation
9+
{
10+
/// <summary>
11+
/// Initializes a new instance of the <see cref="PackageUserInformation"/> class.
12+
/// </summary>
13+
/// <param name="userSecurityId">The user security ID associated with the app package.</param>
14+
/// <param name="installState">The install state of the app package for the user.</param>
15+
public PackageUserInformation(PackageUserSecurityId userSecurityId, string installState)
16+
{
17+
ArgumentNullException.ThrowIfNull(userSecurityId);
18+
ArgumentException.ThrowIfNullOrWhiteSpace(installState);
19+
UserSecurityId = userSecurityId;
20+
InstallState = installState;
21+
}
22+
23+
/// <summary>
24+
/// Gets the user security ID associated with the app package.
25+
/// </summary>
26+
public PackageUserSecurityId UserSecurityId { get; }
27+
28+
/// <summary>
29+
/// Gets the install state of the app package for the user.
30+
/// </summary>
31+
public string InstallState { get; }
32+
}
33+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
using System.Security.Principal;
2+
3+
namespace PSADT.AppManagement
4+
{
5+
/// <summary>
6+
/// Represents the user information associated with an app package.
7+
/// </summary>
8+
public sealed record PackageUserSecurityId
9+
{
10+
/// <summary>
11+
/// Initializes a new instance of the <see cref="PackageUserSecurityId"/> class.
12+
/// </summary>
13+
/// <param name="sid">The security identifier (SID) of the user.</param>
14+
/// <param name="username">The NT account name of the user.</param>
15+
public PackageUserSecurityId(SecurityIdentifier sid, NTAccount username)
16+
{
17+
Sid = sid;
18+
Username = username;
19+
}
20+
21+
/// <summary>
22+
/// Gets the security identifier (SID) of the user.
23+
/// </summary>
24+
public SecurityIdentifier Sid { get; }
25+
26+
/// <summary>
27+
/// Gets the NT account name of the user.
28+
/// </summary>
29+
public NTAccount Username { get; }
30+
}
31+
}

0 commit comments

Comments
 (0)