Exemplo n.º 1
0
        public Database(string storePath, DatabaseMode mode = DatabaseMode.Synchronous)
        {
            store     = new DatabaseStore(storePath);
            this.mode = mode;

            switch (mode)
            {
            case DatabaseMode.Synchronous:
                saveUnderTxAsync = tx =>
                                   Task.FromResult(tx.EnlistVolatile(new SynchronousSaveResourceManager(SaveInternalAsync), EnlistmentOptions.None));
                break;

            case DatabaseMode.Dangerous:
                saveUnderTxAsync = tx =>
                                   Task.FromResult(tx.EnlistVolatile(new DangerousResourceManager(SaveInternalAsync), EnlistmentOptions.None));
                break;

            case DatabaseMode.AsyncBlocking:
                saveUnderTxAsync = tx =>
                                   Task.FromResult(tx.EnlistVolatile(new AsynchronousBlockingResourceManager(SaveInternalAsync), EnlistmentOptions.None));
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Exemplo n.º 2
0
        public Database(string storePath, DatabaseMode mode = DatabaseMode.Synchronous)
        {
            store = new DatabaseStore(storePath);
            this.mode = mode;

            switch (mode)
            {
                case DatabaseMode.Synchronous:
                    saveUnderTxAsync = tx => 
                    Task.FromResult(tx.EnlistVolatile(new SynchronousSaveResourceManager(SaveInternalAsync), EnlistmentOptions.None));
                    break;
                case DatabaseMode.Dangerous:
                    saveUnderTxAsync = tx => 
                    Task.FromResult(tx.EnlistVolatile(new DangerousResourceManager(SaveInternalAsync), EnlistmentOptions.None));
                    break;
                case DatabaseMode.AsyncBlocking:
                    saveUnderTxAsync = tx => 
                    Task.FromResult(tx.EnlistVolatile(new AsynchronousBlockingResourceManager(SaveInternalAsync), EnlistmentOptions.None));
                    break;
                default:
                    throw new ArgumentOutOfRangeException();
            }
        }