mirror of https://github.com/abpframework/abp.git
14 changed files with 200 additions and 26 deletions
@ -0,0 +1,19 @@ |
|||
using System.Reflection; |
|||
using System.Runtime.CompilerServices; |
|||
using System.Runtime.InteropServices; |
|||
|
|||
// General Information about an assembly is controlled through the following
|
|||
// set of attributes. Change these attribute values to modify the information
|
|||
// associated with an assembly.
|
|||
[assembly: AssemblyConfiguration("")] |
|||
[assembly: AssemblyCompany("")] |
|||
[assembly: AssemblyProduct("Volo.Abp.AspNetCore.MultiTenancy")] |
|||
[assembly: AssemblyTrademark("")] |
|||
|
|||
// Setting ComVisible to false makes the types in this assembly not visible
|
|||
// to COM components. If you need to access a type in this assembly from
|
|||
// COM, set the ComVisible attribute to true on that type.
|
|||
[assembly: ComVisible(false)] |
|||
|
|||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
|||
[assembly: Guid("7cc7946b-e026-4f66-8d4f-4f78f4801d43")] |
|||
@ -0,0 +1,20 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
|||
<PropertyGroup> |
|||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion> |
|||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath> |
|||
</PropertyGroup> |
|||
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" /> |
|||
<PropertyGroup Label="Globals"> |
|||
<ProjectGuid>7cc7946b-e026-4f66-8d4f-4f78f4801d43</ProjectGuid> |
|||
<RootNamespace> |
|||
</RootNamespace> |
|||
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath> |
|||
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath> |
|||
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion> |
|||
</PropertyGroup> |
|||
<PropertyGroup> |
|||
<SchemaVersion>2.0</SchemaVersion> |
|||
</PropertyGroup> |
|||
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" /> |
|||
</Project> |
|||
@ -0,0 +1,14 @@ |
|||
{ |
|||
"version": "1.0.0-*", |
|||
|
|||
"dependencies": { |
|||
"NETStandard.Library": "1.6.1", |
|||
"Volo.Abp.MultiTenancy": "1.0.0-*" |
|||
}, |
|||
|
|||
"frameworks": { |
|||
"netstandard1.6": { |
|||
"imports": "dnxcore50" |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,21 @@ |
|||
using System.Threading; |
|||
using Volo.DependencyInjection; |
|||
|
|||
namespace Volo.Abp.MultiTenancy |
|||
{ |
|||
public class AmbientTenantAccessor : IAmbientTenantAccessor, ISingletonDependency //TODO: Should be IScopedDependency?
|
|||
{ |
|||
public AmbientTenantInfo AmbientTenant |
|||
{ |
|||
get { return _tenant.Value; } |
|||
set { _tenant.Value = value; } |
|||
} |
|||
|
|||
private readonly AsyncLocal<AmbientTenantInfo> _tenant; |
|||
|
|||
public AmbientTenantAccessor() |
|||
{ |
|||
_tenant = new AsyncLocal<AmbientTenantInfo>(); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,22 @@ |
|||
using JetBrains.Annotations; |
|||
|
|||
namespace Volo.Abp.MultiTenancy |
|||
{ |
|||
public interface IAmbientTenantAccessor |
|||
{ |
|||
AmbientTenantInfo AmbientTenant { get; set; } |
|||
} |
|||
|
|||
public class AmbientTenantInfo |
|||
{ |
|||
/// <summary>
|
|||
/// Null for host.
|
|||
/// </summary>
|
|||
public TenantInfo Tenant { get; set; } |
|||
|
|||
public AmbientTenantInfo([CanBeNull] TenantInfo tenant) |
|||
{ |
|||
Tenant = tenant; |
|||
} |
|||
} |
|||
} |
|||
@ -1,7 +1,11 @@ |
|||
using System; |
|||
|
|||
namespace Volo.Abp.MultiTenancy |
|||
{ |
|||
public interface IMultiTenancyManager |
|||
{ |
|||
ITenantInfo CurrentTenant { get; } |
|||
TenantInfo CurrentTenant { get; } |
|||
|
|||
IDisposable ChangeTenant(TenantInfo tenantInfo); |
|||
} |
|||
} |
|||
@ -1,9 +0,0 @@ |
|||
namespace Volo.Abp.MultiTenancy |
|||
{ |
|||
public interface ITenantInfo |
|||
{ |
|||
string Id { get; } |
|||
|
|||
string Name { get; } |
|||
} |
|||
} |
|||
@ -0,0 +1,29 @@ |
|||
using System; |
|||
|
|||
namespace Volo.Abp |
|||
{ |
|||
/// <summary>
|
|||
/// This class can be used to provide an action when
|
|||
/// Dipose method is called.
|
|||
/// </summary>
|
|||
public class DisposeAction : IDisposable |
|||
{ |
|||
private readonly Action _action; |
|||
|
|||
/// <summary>
|
|||
/// Creates a new <see cref="DisposeAction"/> object.
|
|||
/// </summary>
|
|||
/// <param name="action">Action to be executed when this object is disposed.</param>
|
|||
public DisposeAction(Action action) |
|||
{ |
|||
Check.NotNull(action, nameof(action)); |
|||
|
|||
_action = action; |
|||
} |
|||
|
|||
public void Dispose() |
|||
{ |
|||
_action(); |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue