Пример #1
0
            /// <exception cref="Db4objects.Db4o.Ext.Db4oIOException"></exception>
            public FileBin(BinConfiguration config)
            {
                bool ok = false;

                try
                {
                    _path = new Sharpen.IO.File(config.Uri()).GetCanonicalPath();
                    _file = RandomAccessFileFactory.NewRandomAccessFile(_path, config.ReadOnly(), config
                                                                        .LockFile());
                    if (config.InitialLength() > 0)
                    {
                        Write(config.InitialLength() - 1, new byte[] { 0 }, 1);
                    }
                    ok = true;
                }
                catch (IOException e)
                {
                    throw new Db4oIOException(e);
                }
                finally
                {
                    if (!ok)
                    {
                        Close();
                    }
                }
            }
Пример #2
0
		/// <exception cref="Db4objects.Db4o.Ext.Db4oIOException"></exception>
		public virtual IBin Open(BinConfiguration config)
		{
			IoAdapterStorage.IoAdapterBin bin = new IoAdapterStorage.IoAdapterBin(_io.Open(config
				.Uri(), config.LockFile(), config.InitialLength(), config.ReadOnly()));
			((IBlockSize)Environments.My(typeof(IBlockSize))).Register(bin);
			return bin;
		}
Пример #3
0
			/// <exception cref="Db4objects.Db4o.Ext.Db4oIOException"></exception>
			public FileBin(BinConfiguration config)
			{
				bool ok = false;
				try
				{
					_path = new Sharpen.IO.File(config.Uri()).GetCanonicalPath();
					_file = RandomAccessFileFactory.NewRandomAccessFile(_path, config.ReadOnly(), config
						.LockFile());
					if (config.InitialLength() > 0)
					{
						Write(config.InitialLength() - 1, new byte[] { 0 }, 1);
					}
					ok = true;
				}
				catch (IOException e)
				{
					throw new Db4oIOException(e);
				}
				finally
				{
					if (!ok)
					{
						Close();
					}
				}
			}
Пример #4
0
		/// <summary>opens a Bin for the given URI.</summary>
		/// <remarks>opens a Bin for the given URI.</remarks>
		/// <exception cref="Db4objects.Db4o.Ext.Db4oIOException"></exception>
		public override IBin Open(BinConfiguration config)
		{
			IBin storage = base.Open(config);
			if (config.ReadOnly())
			{
				return new ReadOnlyBin(new CachingStorage.NonFlushingCachingBin(storage, NewCache
					(), _pageCount, _pageSize));
			}
			return new CachingBin(storage, NewCache(), _pageCount, _pageSize);
		}
Пример #5
0
        /// <summary>opens a Bin for the given URI.</summary>
        /// <remarks>opens a Bin for the given URI.</remarks>
        /// <exception cref="Db4objects.Db4o.Ext.Db4oIOException"></exception>
        public override IBin Open(BinConfiguration config)
        {
            IBin storage = base.Open(config);

            if (config.ReadOnly())
            {
                return(new ReadOnlyBin(new CachingStorage.NonFlushingCachingBin(storage, NewCache
                                                                                    (), _pageCount, _pageSize)));
            }
            return(new CachingBin(storage, NewCache(), _pageCount, _pageSize));
        }
Пример #6
0
		private BinConfiguration PointToNewUri(BinConfiguration oldConfig, string newUri)
		{
			return new BinConfiguration(newUri, oldConfig.LockFile(), oldConfig.InitialLength
				(), oldConfig.ReadOnly());
		}
Пример #7
0
 private BinConfiguration PointToNewUri(BinConfiguration oldConfig, string newUri)
 {
     return(new BinConfiguration(newUri, oldConfig.LockFile(), oldConfig.InitialLength
                                     (), oldConfig.ReadOnly()));
 }
Пример #8
0
		/// <summary>opens a MemoryBin for the given URI (name can be freely chosen).</summary>
		/// <remarks>opens a MemoryBin for the given URI (name can be freely chosen).</remarks>
		/// <exception cref="Db4objects.Db4o.Ext.Db4oIOException"></exception>
		public virtual IBin Open(BinConfiguration config)
		{
			IBin storage = ProduceStorage(config);
			return config.ReadOnly() ? new ReadOnlyBin(storage) : storage;
		}
Пример #9
0
 private static FileAccess FileAccessFor(BinConfiguration config)
 {
     return(config.ReadOnly() ? FileAccess.Read : FileAccess.ReadWrite);
 }
Пример #10
0
        /// <summary>opens a MemoryBin for the given URI (name can be freely chosen).</summary>
        /// <remarks>opens a MemoryBin for the given URI (name can be freely chosen).</remarks>
        /// <exception cref="Db4objects.Db4o.Ext.Db4oIOException"></exception>
        public virtual IBin Open(BinConfiguration config)
        {
            IBin storage = ProduceStorage(config);

            return(config.ReadOnly() ? new ReadOnlyBin(storage) : storage);
        }
Пример #11
0
 /// <exception cref="Db4objects.Db4o.Ext.Db4oIOException"></exception>
 public virtual IBin Open(BinConfiguration config)
 {
     IoAdapterStorage.IoAdapterBin bin = new IoAdapterStorage.IoAdapterBin(_io.Open(config
                                                                                    .Uri(), config.LockFile(), config.InitialLength(), config.ReadOnly()));
     ((IBlockSize)Environments.My(typeof(IBlockSize))).Register(bin);
     return(bin);
 }
Пример #12
0
        /// <summary>opens a MemoryBin for the given URI (name can be freely chosen).</summary>
        /// <remarks>opens a MemoryBin for the given URI (name can be freely chosen).</remarks>
        /// <exception cref="Db4objects.Db4o.Ext.Db4oIOException"></exception>
        public virtual IBin Open(BinConfiguration config)
        {
            var bin = ProduceBin(config);

            return(config.ReadOnly() ? new ReadOnlyBin(bin) : bin);
        }
Пример #13
0
		/// <summary>opens a MemoryBin for the given URI (name can be freely chosen).</summary>
		/// <remarks>opens a MemoryBin for the given URI (name can be freely chosen).</remarks>
		/// <exception cref="Db4objects.Db4o.Ext.Db4oIOException"></exception>
		public virtual IBin Open(BinConfiguration config)
		{
			IBin bin = AcquireBin(config);
			return config.ReadOnly() ? new ReadOnlyBin(bin) : bin;
		}
Пример #14
0
        /// <summary>opens a MemoryBin for the given URI (name can be freely chosen).</summary>
        /// <remarks>opens a MemoryBin for the given URI (name can be freely chosen).</remarks>
        /// <exception cref="Db4objects.Db4o.Ext.Db4oIOException"></exception>
        public virtual IBin Open(BinConfiguration config)
        {
            IBin bin = AcquireBin(config);

            return(config.ReadOnly() ? new ReadOnlyBin(bin) : bin);
        }
Пример #15
0
 	private static FileAccess FileAccessFor(BinConfiguration config)
 	{
 		return config.ReadOnly() ? FileAccess.Read : FileAccess.ReadWrite;
 	}
Пример #16
0
 /// <summary>opens a MemoryBin for the given URI (name can be freely chosen).</summary>
 /// <remarks>opens a MemoryBin for the given URI (name can be freely chosen).</remarks>
 /// <exception cref="Db4objects.Db4o.Ext.Db4oIOException"></exception>
 public virtual IBin Open(BinConfiguration config)
 {
     var bin = ProduceBin(config);
     return config.ReadOnly() ? new ReadOnlyBin(bin) : bin;
 }