Пример #1
0
        /// <summary>
        /// Checks if the database contains a table with the given name.
        /// </summary>
        /// <param name="item">case-sensitive name of the table to search for</param>
        /// <returns>True if the table exists, false otherwise.</returns>
        public bool Contains(string item)
        {
            if (String.IsNullOrEmpty(item))
            {
                throw new ArgumentNullException("item");
            }
            uint ret = RemotableNativeMethods.MsiDatabaseIsTablePersistent((int)this.db.Handle, item);

            if (ret == 3)  // MSICONDITION_ERROR
            {
                throw new InstallerException();
            }
            return(ret != 2);  // MSICONDITION_NONE
        }
Пример #2
0
        /// <summary>
        /// Checks whether a table exists and is persistent in the database.
        /// </summary>
        /// <param name="table">The table to the checked</param>
        /// <returns>true if the table exists and is persistent in the database; false otherwise</returns>
        /// <exception cref="ArgumentException">the table is unknown</exception>
        /// <exception cref="InvalidHandleException">the Database handle is invalid</exception>
        /// <remarks><p>
        /// To check whether a table exists regardless of persistence,
        /// use <see cref="TableCollection.Contains"/>.
        /// </p><p>
        /// Win32 MSI API:
        /// <a href="http://msdn.microsoft.com/library/en-us/msi/setup/msidatabaseistablepersistent.asp">MsiDatabaseIsTablePersistent</a>
        /// </p></remarks>
        public bool IsTablePersistent(string table)
        {
            if (String.IsNullOrEmpty(table))
            {
                throw new ArgumentNullException("table");
            }
            uint ret = RemotableNativeMethods.MsiDatabaseIsTablePersistent((int)this.Handle, table);

            if (ret == 3)  // MSICONDITION_ERROR
            {
                throw new InstallerException();
            }
            return(ret == 1);
        }