NullAbpSession.cs 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. using Abp.Configuration.Startup;
  2. using Abp.MultiTenancy;
  3. using Abp.Runtime.Remoting;
  4. namespace Abp.Runtime.Session
  5. {
  6. /// <summary>
  7. /// Implements null object pattern for <see cref="IAbpSession"/>.
  8. /// </summary>
  9. public class NullAbpSession : AbpSessionBase
  10. {
  11. /// <summary>
  12. /// Singleton instance.
  13. /// </summary>
  14. public static NullAbpSession Instance { get; } = new NullAbpSession();
  15. /// <inheritdoc/>
  16. public override long? UserId => null;
  17. /// <inheritdoc/>
  18. public override int? TenantId => null;
  19. public override MultiTenancySides MultiTenancySide => MultiTenancySides.Tenant;
  20. public override long? ImpersonatorUserId => null;
  21. public override int? ImpersonatorTenantId => null;
  22. private NullAbpSession()
  23. : base(
  24. new MultiTenancyConfig(),
  25. new DataContextAmbientScopeProvider<SessionOverride>(new AsyncLocalAmbientDataContext())
  26. )
  27. {
  28. }
  29. }
  30. }