Esempio n. 1
0
        public static void FileStorage()
        {
            // #example: Using the pure file storage
            IEmbeddedConfiguration configuration = Db4oEmbedded.NewConfiguration();
            IStorage fileStorage = new FileStorage();
            configuration.File.Storage = fileStorage;
            IObjectContainer container = Db4oEmbedded.OpenFile(configuration, "database.db4o");
            // #end example

        }
Esempio n. 2
0
        public static void CachingStorage()
        {
            // #example: Using a caching storage
            IEmbeddedConfiguration configuration = Db4oEmbedded.NewConfiguration();
            IStorage fileStorage = new FileStorage();
            IStorage cachingStorage = new CachingStorage(fileStorage, 128, 1024);
            configuration.File.Storage = cachingStorage;
            IObjectContainer container = Db4oEmbedded.OpenFile(configuration, "database.db4o");
            // #end example

        }
Esempio n. 3
0
        public static void NonFlushingStorage()
        {
            // #example: Using the non-flushing storage
            IEmbeddedConfiguration configuration = Db4oEmbedded.NewConfiguration();
            IStorage fileStorage = new FileStorage();
            // the non-flushing storage improves performance, but risks database corruption.
            IStorage cachingStorage = new NonFlushingStorage(fileStorage);
            configuration.File.Storage = cachingStorage;
            IObjectContainer container = Db4oEmbedded.OpenFile(configuration, "database.db4o");
            // #end example

        }
Esempio n. 4
0
 public static void StorageStack()
 {
     IEmbeddedConfiguration configuration = Db4oEmbedded.NewConfiguration();
     // #example: You stack up different storage-decorator to add functionality
     // the basic file storage
     IStorage fileStorage = new FileStorage();
     // add your own decorator
     IStorage myStorageDecorator = new MyStorageDecorator(fileStorage);
     // add caching to the storage
     IStorage storageWithCaching = new CachingStorage(myStorageDecorator);
     // finally configure db4o with our storage-stack
     configuration.File.Storage = storageWithCaching;
     // #end example
     IObjectContainer container = Db4oEmbedded.OpenFile(configuration, "database.db4o");
 }
Esempio n. 5
0
		/// <exception cref="System.IO.IOException"></exception>
		internal static LocalObjectContainer FreshTempFile(string fileName, int blockSize
			)
		{
			FileStorage storage = new FileStorage();
			storage.Delete(fileName);
			IConfiguration db4oConfig = DefragmentConfig.VanillaDb4oConfig(blockSize);
			db4oConfig.ObjectClass(typeof(IdSlotMapping)).ObjectField("_id").Indexed(true);
			db4oConfig.Storage = storage;
			return (LocalObjectContainer)Db4oFactory.OpenFile(db4oConfig, fileName).Ext();
		}
			/// <exception cref="System.Exception"></exception>
			public virtual void Test()
			{
				if (CommonAndLocalConfigurationTestSuite.Subject() is IClientConfiguration)
				{
					return;
				}
				IFileConfigurationProvider config = ((IFileConfigurationProvider)Subject());
				IFileConfiguration fileConfig = config.File;
				Config4Impl legacyConfig = Db4oLegacyConfigurationBridge.AsLegacy(config);
				fileConfig.BlockSize = 42;
				Assert.AreEqual(42, legacyConfig.BlockSize());
				fileConfig.DatabaseGrowthSize = 42;
				Assert.AreEqual(42, legacyConfig.DatabaseGrowthSize());
				fileConfig.DisableCommitRecovery();
				Assert.IsTrue(legacyConfig.CommitRecoveryDisabled());
				fileConfig.Freespace.DiscardSmallerThan(8);
				Assert.AreEqual(8, legacyConfig.DiscardFreeSpace());
				fileConfig.GenerateUUIDs = ConfigScope.Globally;
				Assert.AreEqual(ConfigScope.Globally, legacyConfig.GenerateUUIDs());
				fileConfig.GenerateCommitTimestamps = true;
				Assert.IsTrue(legacyConfig.GenerateCommitTimestamps().DefiniteYes());
				IStorage storageFactory = new FileStorage();
				fileConfig.Storage = storageFactory;
				Assert.AreSame(storageFactory, legacyConfig.Storage);
				Assert.AreSame(storageFactory, fileConfig.Storage);
				fileConfig.LockDatabaseFile = true;
				Assert.IsTrue(legacyConfig.LockFile());
				fileConfig.ReserveStorageSpace = 1024;
				Assert.AreEqual(1024, legacyConfig.ReservedStorageSpace());
				fileConfig.BlobPath = Path.GetTempPath();
				Assert.AreEqual(Path.GetTempPath(), legacyConfig.BlobPath());
				fileConfig.ReadOnly = true;
				Assert.IsTrue(legacyConfig.IsReadOnly());
				ICacheConfigurationProvider cacheProvider = ((ICacheConfigurationProvider)Subject
					());
				ICacheConfiguration cache = cacheProvider.Cache;
				IIdSystemConfigurationProvider idSystemConfigurationProvider = ((IIdSystemConfigurationProvider
					)Subject());
				IIdSystemConfiguration idSystemConfiguration = idSystemConfigurationProvider.IdSystem;
				Assert.AreEqual(StandardIdSystemFactory.Default, legacyConfig.IdSystemType());
				idSystemConfiguration.UseStackedBTreeSystem();
				Assert.AreEqual(StandardIdSystemFactory.StackedBtree, legacyConfig.IdSystemType()
					);
				idSystemConfiguration.UsePointerBasedSystem();
				Assert.AreEqual(StandardIdSystemFactory.PointerBased, legacyConfig.IdSystemType()
					);
			}
Esempio n. 7
0
		private IEmbeddedConfiguration NewConfiguration(int itemCount)
		{
			FileStorage rafAdapter = new FileStorage();
			IStorage ioAdapter = new LoggingStorage(rafAdapter, LogFileName(itemCount));
			IEmbeddedConfiguration config = Db4oEmbedded.NewConfiguration();
			config.File.Storage = ioAdapter;
			return config;
		}