-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
82b7d4f
commit 8d0f159
Showing
34 changed files
with
228 additions
and
181 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
DragonSpark.Application/Entities/Transactions/AssignAmbientComponentsTransaction.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using Microsoft.EntityFrameworkCore; | ||
using System; | ||
|
||
namespace DragonSpark.Application.Entities.Transactions; | ||
|
||
sealed class AssignAmbientComponentsTransaction : AppendedTransaction | ||
{ | ||
public AssignAmbientComponentsTransaction(IServiceProvider first, DbContext second) | ||
: base(new AssignAmbientProviderTransaction(first), new AssignAmbientEntityContextTransaction(second)) {} | ||
} |
36 changes: 36 additions & 0 deletions
36
DragonSpark.Application/Entities/Transactions/AssignAmbientEntityContextTransaction.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using DragonSpark.Model; | ||
using Microsoft.EntityFrameworkCore; | ||
using System; | ||
using System.Threading.Tasks; | ||
|
||
namespace DragonSpark.Application.Entities.Transactions; | ||
|
||
sealed class AssignAmbientEntityContextTransaction : StoreTransaction<DbContext> | ||
{ | ||
public AssignAmbientEntityContextTransaction(DbContext context) : base(context, LogicalContext.Default) {} | ||
} | ||
|
||
// TODO | ||
|
||
sealed class DisposingTransaction : ITransaction | ||
{ | ||
readonly IDisposable _disposable; | ||
|
||
public DisposingTransaction(IDisposable disposable) => _disposable = disposable; | ||
|
||
public async ValueTask DisposeAsync() | ||
{ | ||
if (_disposable is IAsyncDisposable disposableAsyncDisposable) | ||
{ | ||
await disposableAsyncDisposable.DisposeAsync().ConfigureAwait(false); | ||
} | ||
else | ||
{ | ||
_disposable.Dispose(); | ||
} | ||
} | ||
|
||
public void Execute(None parameter) {} | ||
|
||
public ValueTask Get() => ValueTask.CompletedTask; | ||
} |
9 changes: 9 additions & 0 deletions
9
DragonSpark.Application/Entities/Transactions/AssignAmbientProviderTransaction.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using DragonSpark.Composition.Scopes; | ||
using System; | ||
|
||
namespace DragonSpark.Application.Entities.Transactions; | ||
|
||
sealed class AssignAmbientProviderTransaction : StoreTransaction<IServiceProvider> | ||
{ | ||
public AssignAmbientProviderTransaction(IServiceProvider value) : base(value, LogicalProvider.Default) {} | ||
} |
49 changes: 0 additions & 49 deletions
49
DragonSpark.Application/Entities/Transactions/CurrentDatabaseTransaction.cs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
DragonSpark.Application/Entities/Transactions/DatabaseTransactions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
using DragonSpark.Compose; | ||
using DragonSpark.Model.Results; | ||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.EntityFrameworkCore.Infrastructure; | ||
using System.Threading.Tasks; | ||
|
||
namespace DragonSpark.Application.Entities.Transactions; | ||
|
||
public sealed class DatabaseTransactions : ITransactions | ||
{ | ||
readonly DbContext _context; | ||
readonly DatabaseFacade _facade; | ||
|
||
public DatabaseTransactions(DbContext owner) : this(owner, owner.Database) {} | ||
|
||
public DatabaseTransactions(DbContext context, DatabaseFacade facade) | ||
{ | ||
_context = context; | ||
_facade = facade; | ||
} | ||
|
||
public async ValueTask<ITransaction> Get() | ||
{ | ||
await _facade.BeginTransactionAsync().ConfigureAwait(false); | ||
return new DatabaseTransaction(_context); | ||
} | ||
} | ||
|
||
// TODO | ||
|
||
public sealed class LogicalDatabaseTransactions : ITransactions | ||
{ | ||
public static LogicalDatabaseTransactions Default { get; } = new(); | ||
|
||
LogicalDatabaseTransactions() : this(LogicalContext.Default) {} | ||
|
||
readonly IResult<DbContext?> _context; | ||
|
||
public LogicalDatabaseTransactions(IResult<DbContext?> context) => _context = context; | ||
|
||
public async ValueTask<ITransaction> Get() | ||
{ | ||
var context = _context.Get().Verify(); | ||
await context.Database.BeginTransactionAsync().ConfigureAwait(false); | ||
return new RequiredDatabaseTransaction(context); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 0 additions & 8 deletions
8
DragonSpark.Application/Entities/Transactions/EstablishSessionCurrentTransactions.cs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.