예제 #1
0
        /// <summary>
        /// Opens existing storage or creates a new one.
        /// </summary>
        /// <param name="path">A string containing information about storage location</param>
        public void OpenOrCreate(string path)
        {
            CheckDisposed();

            if (PageManager == null)
            {
                throw new InvalidOperationException("Page manager is not set");
            }

            if (_isOpen)
            {
                throw new InvalidOperationException("Storage is already open");
            }

            _path = path;
            PageManager.Lock();
            try
            {
                if (PageManager.CanCreate())
                {
                    CreateNew(path);
                }
                else
                {
                    OpenExisting(path);
                }
            }
            finally
            {
                PageManager.Unlock();
            }
        }