mirror of https://github.com/abpframework/abp.git
13 changed files with 203 additions and 14 deletions
@ -0,0 +1,30 @@ |
|||||
|
using System; |
||||
|
using System.Threading.Tasks; |
||||
|
using JetBrains.Annotations; |
||||
|
|
||||
|
namespace Volo.Abp; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// This class can be used to provide an action when
|
||||
|
/// DisposeAsync method is called.
|
||||
|
/// </summary>
|
||||
|
public class AsyncDisposeFunc : IAsyncDisposable |
||||
|
{ |
||||
|
private readonly Func<Task> _func; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Creates a new <see cref="AsyncDisposeFunc"/> object.
|
||||
|
/// </summary>
|
||||
|
/// <param name="func">func to be executed when this object is DisposeAsync.</param>
|
||||
|
public AsyncDisposeFunc([NotNull] Func<Task> func) |
||||
|
{ |
||||
|
Check.NotNull(func, nameof(func)); |
||||
|
|
||||
|
_func = func; |
||||
|
} |
||||
|
|
||||
|
public async ValueTask DisposeAsync() |
||||
|
{ |
||||
|
await _func(); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,19 @@ |
|||||
|
using System; |
||||
|
using System.Threading.Tasks; |
||||
|
|
||||
|
namespace Volo.Abp; |
||||
|
|
||||
|
public sealed class NullAsyncDisposable : IAsyncDisposable |
||||
|
{ |
||||
|
public static NullAsyncDisposable Instance { get; } = new NullAsyncDisposable(); |
||||
|
|
||||
|
private NullAsyncDisposable() |
||||
|
{ |
||||
|
|
||||
|
} |
||||
|
|
||||
|
public ValueTask DisposeAsync() |
||||
|
{ |
||||
|
return default; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,32 @@ |
|||||
|
using System.Threading.Tasks; |
||||
|
using Volo.Abp.DependencyInjection; |
||||
|
using Volo.Abp.MultiTenancy; |
||||
|
|
||||
|
namespace Volo.Abp.FeatureManagement; |
||||
|
|
||||
|
public class NextTenantFeatureManagementProvider : FeatureManagementProvider, ITransientDependency |
||||
|
{ |
||||
|
public static string ProviderName => "TENANT"; |
||||
|
|
||||
|
public override string Name => ProviderName; |
||||
|
|
||||
|
protected ICurrentTenant CurrentTenant { get; } |
||||
|
|
||||
|
public NextTenantFeatureManagementProvider( |
||||
|
IFeatureManagementStore store, |
||||
|
ICurrentTenant currentTenant) |
||||
|
: base(store) |
||||
|
{ |
||||
|
CurrentTenant = currentTenant; |
||||
|
} |
||||
|
|
||||
|
protected override Task<string> NormalizeProviderKeyAsync(string providerKey) |
||||
|
{ |
||||
|
if (providerKey != null) |
||||
|
{ |
||||
|
return Task.FromResult(providerKey); |
||||
|
} |
||||
|
|
||||
|
return Task.FromResult(CurrentTenant.Id?.ToString()); |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue