Inheritance: IFdbDatabaseHandler
Ejemplo n.º 1
0
        public Task <IFdbDatabaseHandler> OpenDatabaseAsync(string databaseName, CancellationToken cancellationToken)
        {
            if (cancellationToken.IsCancellationRequested)
            {
                return(Task.FromCanceled <IFdbDatabaseHandler>(cancellationToken));
            }

            var future = FdbNative.ClusterCreateDatabase(m_handle, databaseName);

            return(FdbFuture.CreateTaskFromHandle(
                       future,
                       (h) =>
            {
                DatabaseHandle database;
                var err = FdbNative.FutureGetDatabase(h, out database);
                if (err != FdbError.Success)
                {
                    database.Dispose();
                    throw Fdb.MapToException(err);
                }
                var handler = new FdbNativeDatabase(database);
                return (IFdbDatabaseHandler)handler;
            },
                       cancellationToken
                       ));
        }
Ejemplo n.º 2
0
        public FdbNativeTransaction(FdbNativeDatabase db, TransactionHandle handle)
        {
            Contract.NotNull(db, nameof(db));
            Contract.NotNull(handle, nameof(handle));

            m_database = db;
            m_handle   = handle;
#if CAPTURE_STACKTRACES
            m_stackTrace = new StackTrace();
#endif
        }
		public FdbNativeTransaction(FdbNativeDatabase db, TransactionHandle handle)
		{
			if (db == null) throw new ArgumentNullException("db");
			if (handle == null) throw new ArgumentNullException("handle");

			m_database = db;
			m_handle = handle;
#if CAPTURE_STACKTRACES
			m_stackTrace = new StackTrace();
#endif
		}
        public Task <IFdbDatabaseHandler> OpenDatabaseAsync(string databaseName, CancellationToken ct)
        {
            if (ct.IsCancellationRequested)
            {
                return(Task.FromCanceled <IFdbDatabaseHandler>(ct));
            }

            return(Task.Run(() => {
                var handler = new FdbNativeDatabase(CreateDatabase("/usr/local/etc/foundationdb/fdb.cluster"));
                return (IFdbDatabaseHandler)handler;
            }));
        }
        public FdbNativeTransaction(FdbNativeDatabase db, TransactionHandle handle)
        {
            if (db == null)
            {
                throw new ArgumentNullException("db");
            }
            if (handle == null)
            {
                throw new ArgumentNullException("handle");
            }

            m_database = db;
            m_handle   = handle;
#if CAPTURE_STACKTRACES
            m_stackTrace = new StackTrace();
#endif
        }
		public Task<IFdbDatabaseHandler> OpenDatabaseAsync(string databaseName, CancellationToken cancellationToken)
		{
			if (cancellationToken.IsCancellationRequested) return TaskHelpers.FromCancellation<IFdbDatabaseHandler>(cancellationToken);

			var future = FdbNative.ClusterCreateDatabase(m_handle, databaseName);
			return FdbFuture.CreateTaskFromHandle(
				future,
				(h) =>
				{
					DatabaseHandle database;
					var err = FdbNative.FutureGetDatabase(h, out database);
					if (err != FdbError.Success)
					{
						database.Dispose();
						throw Fdb.MapToException(err);
					}
					var handler = new FdbNativeDatabase(database);
                    return (IFdbDatabaseHandler) handler;
				},
				cancellationToken
			);
		}