diff options
| author | Sean Hall <r.sean.hall@gmail.com> | 2023-01-19 00:18:26 -0600 |
|---|---|---|
| committer | Sean Hall <r.sean.hall@gmail.com> | 2023-01-19 01:52:41 -0600 |
| commit | a46ef0eebafea0e5b38c0c6e960be778c2dbb852 (patch) | |
| tree | 8ae23b506375da6ff91e5f0743006a7ccd51ecc0 /src/api/burn/WixToolset.Mba.Core/Engine.cs | |
| parent | 7a0aa56131ba7fa3b63788908c164d0f8118e3fc (diff) | |
| download | wix-a46ef0eebafea0e5b38c0c6e960be778c2dbb852.tar.gz wix-a46ef0eebafea0e5b38c0c6e960be778c2dbb852.tar.bz2 wix-a46ef0eebafea0e5b38c0c6e960be778c2dbb852.zip | |
Finish the XML documentation in WixToolset.Mba.Core.
4623
Diffstat (limited to 'src/api/burn/WixToolset.Mba.Core/Engine.cs')
| -rw-r--r-- | src/api/burn/WixToolset.Mba.Core/Engine.cs | 83 |
1 files changed, 0 insertions, 83 deletions
diff --git a/src/api/burn/WixToolset.Mba.Core/Engine.cs b/src/api/burn/WixToolset.Mba.Core/Engine.cs index 3ff693c0..1120fb1c 100644 --- a/src/api/burn/WixToolset.Mba.Core/Engine.cs +++ b/src/api/burn/WixToolset.Mba.Core/Engine.cs | |||
| @@ -6,21 +6,14 @@ namespace WixToolset.Mba.Core | |||
| 6 | using System.ComponentModel; | 6 | using System.ComponentModel; |
| 7 | using System.Runtime.InteropServices; | 7 | using System.Runtime.InteropServices; |
| 8 | using System.Security; | 8 | using System.Security; |
| 9 | using System.Text; | ||
| 10 | 9 | ||
| 11 | /// <summary> | 10 | /// <summary> |
| 12 | /// Default implementation of <see cref="IEngine"/>. | 11 | /// Default implementation of <see cref="IEngine"/>. |
| 13 | /// </summary> | 12 | /// </summary> |
| 14 | public sealed class Engine : IEngine | 13 | public sealed class Engine : IEngine |
| 15 | { | 14 | { |
| 16 | private static readonly string normalizeVersionFormatString = "{0} must be less than or equal to " + UInt16.MaxValue; | ||
| 17 | |||
| 18 | private IBootstrapperEngine engine; | 15 | private IBootstrapperEngine engine; |
| 19 | 16 | ||
| 20 | /// <summary> | ||
| 21 | /// Creates a new instance of the <see cref="Engine"/> container class. | ||
| 22 | /// </summary> | ||
| 23 | /// <param name="engine">The <see cref="IBootstrapperEngine"/> to contain.</param> | ||
| 24 | internal Engine(IBootstrapperEngine engine) | 17 | internal Engine(IBootstrapperEngine engine) |
| 25 | { | 18 | { |
| 26 | this.engine = engine; | 19 | this.engine = engine; |
| @@ -352,81 +345,5 @@ namespace WixToolset.Mba.Core | |||
| 352 | { | 345 | { |
| 353 | this.engine.Quit(exitCode); | 346 | this.engine.Quit(exitCode); |
| 354 | } | 347 | } |
| 355 | |||
| 356 | /// <summary> | ||
| 357 | /// Utility method for converting a <see cref="Version"/> into a <see cref="long"/>. | ||
| 358 | /// </summary> | ||
| 359 | /// <param name="version"></param> | ||
| 360 | /// <returns></returns> | ||
| 361 | public static long VersionToLong(Version version) | ||
| 362 | { | ||
| 363 | // In Windows, each version component has a max value of 65535, | ||
| 364 | // so we truncate the version before shifting it, which will overflow if invalid. | ||
| 365 | long major = (long)(ushort)version.Major << 48; | ||
| 366 | long minor = (long)(ushort)version.Minor << 32; | ||
| 367 | long build = (long)(ushort)version.Build << 16; | ||
| 368 | long revision = (long)(ushort)version.Revision; | ||
| 369 | |||
| 370 | return major | minor | build | revision; | ||
| 371 | } | ||
| 372 | |||
| 373 | /// <summary> | ||
| 374 | /// Utility method for converting a <see cref="long"/> into a <see cref="Version"/>. | ||
| 375 | /// </summary> | ||
| 376 | /// <param name="version"></param> | ||
| 377 | /// <returns></returns> | ||
| 378 | public static Version LongToVersion(long version) | ||
| 379 | { | ||
| 380 | int major = (int)((version & ((long)0xffff << 48)) >> 48); | ||
| 381 | int minor = (int)((version & ((long)0xffff << 32)) >> 32); | ||
| 382 | int build = (int)((version & ((long)0xffff << 16)) >> 16); | ||
| 383 | int revision = (int)(version & 0xffff); | ||
| 384 | |||
| 385 | return new Version(major, minor, build, revision); | ||
| 386 | } | ||
| 387 | |||
| 388 | /// <summary> | ||
| 389 | /// Verifies that Version can be represented in a <see cref="long"/>. | ||
| 390 | /// If the Build or Revision fields are undefined, they are set to zero. | ||
| 391 | /// </summary> | ||
| 392 | public static Version NormalizeVersion(Version version) | ||
| 393 | { | ||
| 394 | if (version == null) | ||
| 395 | { | ||
| 396 | throw new ArgumentNullException("version"); | ||
| 397 | } | ||
| 398 | |||
| 399 | int major = version.Major; | ||
| 400 | int minor = version.Minor; | ||
| 401 | int build = version.Build; | ||
| 402 | int revision = version.Revision; | ||
| 403 | |||
| 404 | if (major > UInt16.MaxValue) | ||
| 405 | { | ||
| 406 | throw new ArgumentOutOfRangeException("version", String.Format(normalizeVersionFormatString, "Major")); | ||
| 407 | } | ||
| 408 | if (minor > UInt16.MaxValue) | ||
| 409 | { | ||
| 410 | throw new ArgumentOutOfRangeException("version", String.Format(normalizeVersionFormatString, "Minor")); | ||
| 411 | } | ||
| 412 | if (build > UInt16.MaxValue) | ||
| 413 | { | ||
| 414 | throw new ArgumentOutOfRangeException("version", String.Format(normalizeVersionFormatString, "Build")); | ||
| 415 | } | ||
| 416 | if (build == -1) | ||
| 417 | { | ||
| 418 | build = 0; | ||
| 419 | } | ||
| 420 | if (revision > UInt16.MaxValue) | ||
| 421 | { | ||
| 422 | throw new ArgumentOutOfRangeException("version", String.Format(normalizeVersionFormatString, "Revision")); | ||
| 423 | } | ||
| 424 | if (revision == -1) | ||
| 425 | { | ||
| 426 | revision = 0; | ||
| 427 | } | ||
| 428 | |||
| 429 | return new Version(major, minor, build, revision); | ||
| 430 | } | ||
| 431 | } | 348 | } |
| 432 | } | 349 | } |
