Пример #1
0
        private bool TryCreateEsentStorage(string workingFolderPath, string solutionPath, out AbstractPersistentStorage esentStorage)
        {
            esentStorage = null;
            EsentPersistentStorage esent = null;

            try
            {
                esent = new EsentPersistentStorage(_optionService, workingFolderPath, solutionPath, this.Release);
                esent.Initialize();

                esentStorage = esent;
                return(true);
            }
            catch (EsentAccessDeniedException ex)
            {
                // esent db is already in use by someone.
                if (esent != null)
                {
                    esent.Close();
                }

                EsentLogger.LogException(ex);

                return(false);
            }
            catch (Exception ex)
            {
                if (esent != null)
                {
                    esent.Close();
                }

                EsentLogger.LogException(ex);
            }

            try
            {
                if (esent != null)
                {
                    Directory.Delete(esent.EsentDirectory, recursive: true);
                }
            }
            catch
            {
                // somehow, we couldn't delete the directory.
            }

            return(false);
        }