Esempio n. 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;
            }
            }
        }