示例#1
0
        public static IIdSystem NewInstance(LocalObjectContainer localContainer)
        {
            SystemData systemData   = localContainer.SystemData();
            byte       idSystemType = systemData.IdSystemType();

            switch (idSystemType)
            {
            case Legacy:
            {
                return(new PointerBasedIdSystem(localContainer));
            }

            case PointerBased:
            {
                return(new PointerBasedIdSystem(localContainer));
            }

            case StackedBtree:
            {
                InMemoryIdSystem inMemoryIdSystem = new InMemoryIdSystem(localContainer);
                BTreeIdSystem    bTreeIdSystem    = new BTreeIdSystem(localContainer, inMemoryIdSystem);
                systemData.FreespaceIdSystem(bTreeIdSystem.FreespaceIdSystem());
                return(new BTreeIdSystem(localContainer, bTreeIdSystem));
            }

            case SingleBtree:
            {
                InMemoryIdSystem smallInMemoryIdSystem = new InMemoryIdSystem(localContainer);
                BTreeIdSystem    smallBTreeIdSystem    = new BTreeIdSystem(localContainer, smallInMemoryIdSystem
                                                                           );
                systemData.FreespaceIdSystem(smallBTreeIdSystem.FreespaceIdSystem());
                return(smallBTreeIdSystem);
            }

            case InMemory:
            {
                return(new InMemoryIdSystem(localContainer));
            }

            case Custom:
            {
                IIdSystemFactory customIdSystemFactory = localContainer.ConfigImpl.CustomIdSystemFactory
                                                             ();
                if (customIdSystemFactory == null)
                {
                    throw new Db4oFatalException("Custom IdSystem configured but no factory was found. See IdSystemConfiguration#useCustomSystem()"
                                                 );
                }
                return(customIdSystemFactory.NewInstance(localContainer));
            }

            default:
            {
                return(new PointerBasedIdSystem(localContainer));

                break;
            }
            }
        }
			/// <exception cref="System.Exception"></exception>
			protected override void Configure(IConfiguration config)
			{
				if (Platform4.NeedsLockFileThread())
				{
					config.LockDatabaseFile(false);
				}
				IExceptionPropagationFixture propagationFixture = CurrentExceptionPropagationFixture
					();
				IExceptionFactory exceptionFactory = new _IExceptionFactory_37(propagationFixture
					);
				_storage = new ExceptionSimulatingStorage(config.Storage, exceptionFactory);
				config.Storage = _storage;
				_idSystemFactory = new _IIdSystemFactory_61(this, exceptionFactory);
				ConfigureIdSystem(config);
			}
            /// <exception cref="System.Exception"></exception>
            protected override void Configure(IConfiguration config)
            {
                if (Platform4.NeedsLockFileThread())
                {
                    config.LockDatabaseFile(false);
                }
                IExceptionPropagationFixture propagationFixture = CurrentExceptionPropagationFixture
                                                                      ();
                IExceptionFactory exceptionFactory = new _IExceptionFactory_37(propagationFixture
                                                                               );

                _storage         = new ExceptionSimulatingStorage(config.Storage, exceptionFactory);
                config.Storage   = _storage;
                _idSystemFactory = new _IIdSystemFactory_61(this, exceptionFactory);
                ConfigureIdSystem(config);
            }
		public void UseCustomIdSystem(IIdSystemFactory factory)
		{
			_config.Put(IdSystemKey, StandardIdSystemFactory.Custom);
			_config.Put(IdSystemCustomFactoryKey, factory);
		}
示例#5
0
 public void UseCustomIdSystem(IIdSystemFactory factory)
 {
     _config.Put(IdSystemKey, StandardIdSystemFactory.Custom);
     _config.Put(IdSystemCustomFactoryKey, factory);
 }
		public virtual void UseCustomSystem(IIdSystemFactory factory)
		{
			_config.UseCustomIdSystem(factory);
		}
 public virtual void UseCustomSystem(IIdSystemFactory factory)
 {
     _config.UseCustomIdSystem(factory);
 }