Beispiel #1
0
        public async Task <Operation> ExportAsync(DatabaseSmugglerExportOptions options, DatabaseSmuggler toDatabase, CancellationToken token = default)
        {
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }
            if (toDatabase == null)
            {
                throw new ArgumentNullException(nameof(toDatabase));
            }

            Operation operation     = null;
            var       importOptions = new DatabaseSmugglerImportOptions(options);

            var tcs = new TaskCompletionSource <object>(TaskCreationOptions.RunContinuationsAsynchronously);

            await ExportAsync(options, async stream =>
            {
                try
                {
                    operation = await toDatabase.ImportAsync(importOptions, stream, token).ConfigureAwait(false);
                    tcs.TrySetResult(null);
                }
                catch (Exception e)
                {
                    tcs.TrySetException(e);
                    throw;
                }
            }, token).ConfigureAwait(false);

            await tcs.Task.ConfigureAwait(false);

            return(operation);
        }
Beispiel #2
0
        public async Task <Operation> ExportAsync(DatabaseSmugglerOptions options, DatabaseSmuggler toDatabase, CancellationToken token = default(CancellationToken))
        {
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }
            if (toDatabase == null)
            {
                throw new ArgumentNullException(nameof(toDatabase));
            }

            var result = await ExportAsync(options, async stream =>
            {
                await toDatabase.ImportAsync(options, stream, token).ConfigureAwait(false);
            }, token).ConfigureAwait(false);

            return(result);
        }