diff options
| author | Rob Mensching <rob@firegiant.com> | 2017-10-14 16:12:07 -0700 |
|---|---|---|
| committer | Rob Mensching <rob@firegiant.com> | 2017-10-14 16:12:07 -0700 |
| commit | dbde9e7104b907bbbaea17e21247d8cafc8b3a4c (patch) | |
| tree | 0f5fbbb6fe12c6b2e5e622a0e18ce4c5b4eb2b96 /src/WixToolset.Core.WindowsInstaller/Msi/Session.cs | |
| parent | fbf986eb97f68396797a89fc7d40dec07b775440 (diff) | |
| download | wix-dbde9e7104b907bbbaea17e21247d8cafc8b3a4c.tar.gz wix-dbde9e7104b907bbbaea17e21247d8cafc8b3a4c.tar.bz2 wix-dbde9e7104b907bbbaea17e21247d8cafc8b3a4c.zip | |
Massive refactoring to introduce the concept of IBackend
Diffstat (limited to 'src/WixToolset.Core.WindowsInstaller/Msi/Session.cs')
| -rw-r--r-- | src/WixToolset.Core.WindowsInstaller/Msi/Session.cs | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/src/WixToolset.Core.WindowsInstaller/Msi/Session.cs b/src/WixToolset.Core.WindowsInstaller/Msi/Session.cs new file mode 100644 index 00000000..d3a19711 --- /dev/null +++ b/src/WixToolset.Core.WindowsInstaller/Msi/Session.cs | |||
| @@ -0,0 +1,45 @@ | |||
| 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. | ||
| 2 | |||
| 3 | namespace WixToolset.Msi | ||
| 4 | { | ||
| 5 | using System; | ||
| 6 | using System.ComponentModel; | ||
| 7 | using System.Globalization; | ||
| 8 | using WixToolset.Core.Native; | ||
| 9 | |||
| 10 | /// <summary> | ||
| 11 | /// Controls the installation process. | ||
| 12 | /// </summary> | ||
| 13 | internal sealed class Session : MsiHandle | ||
| 14 | { | ||
| 15 | /// <summary> | ||
| 16 | /// Instantiate a new Session. | ||
| 17 | /// </summary> | ||
| 18 | /// <param name="database">The database to open.</param> | ||
| 19 | public Session(Database database) | ||
| 20 | { | ||
| 21 | string packagePath = String.Format(CultureInfo.InvariantCulture, "#{0}", (uint)database.Handle); | ||
| 22 | |||
| 23 | uint handle = 0; | ||
| 24 | int error = MsiInterop.MsiOpenPackage(packagePath, out handle); | ||
| 25 | if (0 != error) | ||
| 26 | { | ||
| 27 | throw new MsiException(error); | ||
| 28 | } | ||
| 29 | this.Handle = handle; | ||
| 30 | } | ||
| 31 | |||
| 32 | /// <summary> | ||
| 33 | /// Executes a built-in action, custom action, or user-interface wizard action. | ||
| 34 | /// </summary> | ||
| 35 | /// <param name="action">Specifies the action to execute.</param> | ||
| 36 | public void DoAction(string action) | ||
| 37 | { | ||
| 38 | int error = MsiInterop.MsiDoAction(this.Handle, action); | ||
| 39 | if (0 != error) | ||
| 40 | { | ||
| 41 | throw new MsiException(error); | ||
| 42 | } | ||
| 43 | } | ||
| 44 | } | ||
| 45 | } | ||
