Skip to content

Commit

Permalink
feat: Adds the tenant value to instances registered as TenantSingleto…
Browse files Browse the repository at this point in the history
…n. You need to inherit IHaveTenant to opt-in for this feature.
  • Loading branch information
mynkow committed Aug 17, 2023
1 parent e6d2339 commit fc54bfb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ public T Get()
if (container.Stash.TryGetValue(context.Tenant, out T instance) == false)
{
instance = context.ServiceProvider.GetRequiredService<T>();
instance.AssignPropertySafely<IHaveTenant>(x => x.Tenant = context.Tenant);
container.Stash.TryAdd(context.Tenant, instance);
}

Expand Down
7 changes: 7 additions & 0 deletions src/Elders.Cronus/Multitenancy/IHaveTenant.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace Elders.Cronus.Multitenancy
{
public interface IHaveTenant
{
string Tenant { get; set; }
}
}

0 comments on commit fc54bfb

Please sign in to comment.