/// <summary> /// Opens an existing database with another database as output. /// </summary> /// <param name="filePath">Path to the database to be read.</param> /// <param name="outputPath">Open mode for the database</param> /// <returns>Database object representing the created or opened database</returns> /// <exception cref="InstallerException">the database could not be created/opened</exception> /// <remarks><p> /// When a database is opened as the output of another database, the summary information stream /// of the output database is actually a read-only mirror of the original database and thus cannot /// be changed. Additionally, it is not persisted with the database. To create or modify the /// summary information for the output database it must be closed and re-opened. /// </p><p> /// The Database object should be <see cref="InstallerHandle.Close"/>d after use. /// It is best that the handle be closed manually as soon as it is no longer /// needed, as leaving lots of unused handles open can degrade performance. /// </p><p> /// The database is opened in <see cref="DatabaseOpenMode.CreateDirect" /> mode, and will be /// automatically commited when it is closed. /// </p><p> /// Win32 MSI API: /// <a href="http://msdn.microsoft.com/library/en-us/msi/setup/msiopendatabase.asp">MsiOpenDatabase</a> /// </p></remarks> public Database(string filePath, string outputPath) : this((IntPtr)Database.Open(filePath, outputPath), true, outputPath, DatabaseOpenMode.CreateDirect) { }
/// <summary> /// Opens an existing database or creates a new one. /// </summary> /// <param name="filePath">Path to the database file. If an empty string /// is supplied, a temporary database is created that is not persisted.</param> /// <param name="mode">Open mode for the database</param> /// <exception cref="InstallerException">the database could not be created/opened</exception> /// <remarks><p> /// Because this constructor initiates database access, it cannot be used with a /// running installation. /// </p><p> /// The database object should be <see cref="InstallerHandle.Close"/>d after use. /// The finalizer will close the handle if it is still open, however due to the nondeterministic /// nature of finalization it is best that the handle be closed manually as soon as it is no /// longer needed, as leaving lots of unused handles open can degrade performance. /// </p><p> /// A database opened in <see cref="DatabaseOpenMode.CreateDirect" /> or /// <see cref="DatabaseOpenMode.Direct" /> mode will be automatically commited when it is /// closed. However a database opened in <see cref="DatabaseOpenMode.Create" /> or /// <see cref="DatabaseOpenMode.Transact" /> mode must have the <see cref="Commit" /> method /// called before it is closed, otherwise no changes will be persisted. /// </p><p> /// Win32 MSI API: /// <a href="http://msdn.microsoft.com/library/en-us/msi/setup/msiopendatabase.asp">MsiOpenDatabase</a> /// </p></remarks> public Database(string filePath, DatabaseOpenMode mode) : this((IntPtr)Database.Open(filePath, mode), true, filePath, mode) { }