示例#1
0
        /// <summary>
        /// Provides access to the drawing database in the given file.
        /// </summary>
        /// <param name="fileName">The name of the drawing database to open.</param>
        /// <param name="openMode">The mode in which the drawing database should be opened.</param>
        /// <param name="password">The password for the darwing database.</param>
        /// <param name="keepOpen">True, if the database should be kept open after it has been used. False, if the database should be closed.</param>
        /// <exception cref="System.ArgumentNullException">Thrown when parameter <i>fileName</i> is null.</exception>
        /// <exception cref="System.IO.FileNotFoundException">Thrown when the file cannot be found.</exception>
        /// <exception cref="System.Exception">Thrown when opening the darwing database throws an exception.</exception>
        /// <returns>The AcadDatabase instance.</returns>
        public static AcadDatabase Open(string fileName, DwgOpenMode openMode, string password, bool keepOpen)
        {
            Require.StringNotEmpty(fileName, nameof(fileName));
            Require.FileExists(fileName, nameof(fileName));

            return(OpenInternal(fileName, openMode, password, keepOpen));
        }
示例#2
0
        /// <summary>
        /// Provides access to the drawing database in the given file.
        /// </summary>
        /// <param name="fileName">The name of the drawing database to open.</param>
        /// <param name="openMode">The mode in which the drawing database should be opened.</param>
        /// <exception cref="System.ArgumentNullException">Thrown when parameter <i>fileName</i> is null.</exception>
        /// <exception cref="System.IO.FileNotFoundException">Thrown when the file cannot be found.</exception>
        /// <exception cref="System.Exception">Thrown when opening the darwing database throws an exception.</exception>
        /// <returns>The AcadDatabase instance.</returns>
        public static AcadDatabase Open(string fileName, DwgOpenMode openMode)
        {
            Require.StringNotEmpty(fileName, nameof(fileName));
            Require.FileExists(fileName, nameof(fileName));

            return(OpenInternal(fileName, openMode, null, false));
        }
示例#3
0
        /// <summary>
        /// Provides access to the drawing database in the given file.
        /// </summary>
        /// <param name="fileName">The name of the drawing database to open.</param>
        /// <param name="openMode">The mode in which the drawing database should be opened.</param>
        /// <param name="password">The password for the darwing database.</param>
        /// <param name="keepOpen">True, if the database should be kept open after it has been used. False, if the database should be closed.</param>
        /// <returns>The AcadDatabase instance.</returns>
        private static AcadDatabase OpenInternal(string fileName, DwgOpenMode openMode, string password, bool keepOpen)
        {
            var database = new Database(false, true);

            database.ReadDwgFile(fileName, openMode == DwgOpenMode.ReadWrite ? FileOpenMode.OpenForReadAndWriteNoShare : FileOpenMode.OpenForReadAndReadShare, false, password);
            database.CloseInput(true);
            return(new AcadDatabase(database, keepOpen));
        }
示例#4
0
        /// <summary>
        /// Provides access to the drawing database in the given file.
        /// </summary>
        /// <param name="fileName">The name of the drawing database to open.</param>
        /// <param name="openMode">The mode in which the drawing database should be opened.</param>
        /// <param name="password">The password for the darwing database.</param>
        /// <exception cref="System.ArgumentNullException">Thrown when parameter <i>fileName</i> is null.</exception>
        /// <exception cref="System.IO.FileNotFoundException">Thrown when the file cannot be found.</exception>
        /// <exception cref="System.Exception">Thrown when opening the darwing database throws an exception.</exception>
        /// <returns>The AcadDatabase instance.</returns>
        public static AcadDatabase Open(string fileName, DwgOpenMode openMode, string password)
        {
            if (fileName == null)
            {
                throw Error.ArgumentNull("fileName");
            }
            if (!File.Exists(fileName))
            {
                throw Error.FileNotFound(fileName);
            }

            try
            {
                return(OpenInternal(fileName, openMode, password, false));
            }
            catch (Exception e)
            {
                throw Error.AutoCadException(e, "Error opening drawing file " + fileName);
            }
        }