mirror of https://github.com/abpframework/abp.git
9 changed files with 83 additions and 9 deletions
@ -0,0 +1,41 @@ |
|||||
|
using System; |
||||
|
using System.Net.Http; |
||||
|
using Microsoft.AspNetCore.Http; |
||||
|
using Volo.Abp.DependencyInjection; |
||||
|
using Volo.Abp.Uow; |
||||
|
|
||||
|
namespace Volo.Abp.AspNetCore.Uow |
||||
|
{ |
||||
|
public class AspNetCoreUnitOfWorkTransactionBehaviourProvider : IUnitOfWorkTransactionBehaviourProvider, ITransientDependency |
||||
|
{ |
||||
|
private readonly IHttpContextAccessor _httpContextAccessor; |
||||
|
|
||||
|
public virtual bool? IsTransactional |
||||
|
{ |
||||
|
get |
||||
|
{ |
||||
|
var httpContext = _httpContextAccessor.HttpContext; |
||||
|
if (httpContext == null) |
||||
|
{ |
||||
|
return null; |
||||
|
} |
||||
|
|
||||
|
//IdentityServer endpoint (TODO: Better to move to the IDS module)
|
||||
|
if (httpContext.Request.Path.Value?.StartsWith("/connect/", StringComparison.OrdinalIgnoreCase) == true) |
||||
|
{ |
||||
|
return false; |
||||
|
} |
||||
|
|
||||
|
return !string.Equals( |
||||
|
httpContext.Request.Method, |
||||
|
HttpMethod.Get.Method, StringComparison.OrdinalIgnoreCase |
||||
|
); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
public AspNetCoreUnitOfWorkTransactionBehaviourProvider(IHttpContextAccessor httpContextAccessor) |
||||
|
{ |
||||
|
_httpContextAccessor = httpContextAccessor; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,7 @@ |
|||||
|
namespace Volo.Abp.Uow |
||||
|
{ |
||||
|
public interface IUnitOfWorkTransactionBehaviourProvider |
||||
|
{ |
||||
|
bool? IsTransactional { get; } |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,9 @@ |
|||||
|
using Volo.Abp.DependencyInjection; |
||||
|
|
||||
|
namespace Volo.Abp.Uow |
||||
|
{ |
||||
|
public class NullUnitOfWorkTransactionBehaviourProvider : IUnitOfWorkTransactionBehaviourProvider, ISingletonDependency |
||||
|
{ |
||||
|
public bool? IsTransactional => null; |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue