45 return _versionString;
67 return _availableVersionString;
78 return _availableVersion;
103 return _hasShortenedId;
118 if (
string.IsNullOrWhiteSpace(_id))
134 if (_availableVersion > _version)
154 if (
string.IsNullOrWhiteSpace(_id) &&
string.IsNullOrWhiteSpace(_name))
163 private protected readonly
string _name;
164 private protected readonly
string _id;
165 private protected readonly
string _versionString;
166 private protected readonly
Version _version;
167 private protected readonly
string _availableVersionString;
168 private protected readonly
Version _availableVersion;
169 private protected readonly
string _sourceName;
171 private protected readonly
bool _hasShortenedId =
false;
188 string versionString,
190 string availableVersionString,
198 _versionString = versionString;
201 _availableVersionString = availableVersionString;
202 _availableVersion = availableVersion;
204 _sourceName = sourceName;
206 _hasShortenedId = hasShortenedId;
227 ArgsHelper.ThrowIfStringIsNullOrWhiteSpace(name,
"name");
228 ArgsHelper.ThrowIfStringIsNullOrWhiteSpace(
id,
"id");
229 ArgsHelper.ThrowIfStringIsNullOrWhiteSpace(version,
"version");
230 ArgsHelper.ThrowIfObjectIsNull(sourceName,
"sourceName");
232 WinGetPackageBuilder builder =
new();
234 builder.AddName(name);
236 builder.AddVersion(version);
237 builder.AddSourceName(sourceName);
239 return builder.GetInstance();
259 public static WinGetPackage Create(
string name,
string id,
string version,
string availableVersion,
string sourceName =
"")
261 ArgsHelper.ThrowIfStringIsNullOrWhiteSpace(name,
"name");
262 ArgsHelper.ThrowIfStringIsNullOrWhiteSpace(
id,
"id");
263 ArgsHelper.ThrowIfStringIsNullOrWhiteSpace(version,
"version");
264 ArgsHelper.ThrowIfStringIsNullOrWhiteSpace(availableVersion,
"availableVersion");
265 ArgsHelper.ThrowIfObjectIsNull(sourceName,
"sourceName");
267 WinGetPackageBuilder builder =
new();
269 builder.AddName(name);
271 builder.AddVersion(version);
272 builder.AddAvailableVersion(availableVersion);
273 builder.AddSourceName(sourceName);
275 return builder.GetInstance();
296 ArgsHelper.ThrowIfStringIsNullOrWhiteSpace(name,
"name");
297 ArgsHelper.ThrowIfStringIsNullOrWhiteSpace(
id,
"id");
298 ArgsHelper.ThrowIfObjectIsNull(version,
"version");
299 ArgsHelper.ThrowIfObjectIsNull(sourceName,
"sourceName");
301 WinGetPackageBuilder builder =
new();
303 builder.AddName(name);
305 builder.AddVersion(version);
306 builder.AddSourceName(sourceName);
308 return builder.GetInstance();
330 ArgsHelper.ThrowIfStringIsNullOrWhiteSpace(name,
"name");
331 ArgsHelper.ThrowIfStringIsNullOrWhiteSpace(
id,
"id");
332 ArgsHelper.ThrowIfObjectIsNull(version,
"version");
333 ArgsHelper.ThrowIfObjectIsNull(availableVersion,
"availableVersion");
334 ArgsHelper.ThrowIfObjectIsNull(sourceName,
"sourceName");
336 WinGetPackageBuilder builder =
new();
338 builder.AddName(name);
340 builder.AddVersion(version);
341 builder.AddAvailableVersion(availableVersion);
342 builder.AddSourceName(sourceName);
344 return builder.GetInstance();
366 if (ReferenceEquals(
this, other))
371 if (_id.Equals(other.
Id) && _sourceName.Equals(other.
SourceName) &&
372 (!sameVersion || (_versionString.Equals(other.
VersionString) && _version.Equals(other.
Version))))
388 _availableVersionString,
398 return $
"{_name} {_versionString}";
Represents a winget package.
static WinGetPackage Create(string name, string id, Version version, string sourceName="")
Creates a new instance of the WGetNET.WinGetPackage class and returns it.
string VersionString
Gets the version of the package.
bool HasUpgrade
Gets if the package can be upgraded.
bool IsEmpty
Gets if the object is empty.
override string ToString()
string Id
Gets the id of the package.
static WinGetPackage Create(string name, string id, Version version, Version availableVersion, string sourceName="")
Creates a new instance of the WGetNET.WinGetPackage class and returns it.
string Name
Gets the name of the package.
static WinGetPackage Create(string name, string id, string version, string sourceName="")
Creates a new instance of the WGetNET.WinGetPackage class and returns it.
string AvailableVersionString
Gets the newest available version of the package.
bool SamePackage(WinGetPackage other, bool sameVersion=false)
Checks if two packages are the same and optionally if they also have the same version.
string SourceName
Gets the source name for the package.
static WinGetPackage Create(string name, string id, string version, string availableVersion, string sourceName="")
Creates a new instance of the WGetNET.WinGetPackage class and returns it.
Version AvailableVersion
Gets the newest available version of the package.
bool HasShortenedId
Gets if id of the package is shortened.
Version Version
Gets the version of the package.
bool HasNoId
Gets if the package does not provide an id.
Interface for all winget related objects.