File tree Expand file tree Collapse file tree 2 files changed +18
-7
lines changed
src/WeihanLi.Web.Extensions/Services Expand file tree Collapse file tree 2 files changed +18
-7
lines changed Original file line number Diff line number Diff line change @@ -58,17 +58,24 @@ IOptions<HttpContextTenantProviderOptions> options
58
58
_httpContextAccessor = httpContextAccessor ;
59
59
_options = options ;
60
60
}
61
- #nullable disable
62
- public string GetTenantId ( )
61
+
62
+ public string ? GetTenantId ( )
63
63
{
64
- ArgumentNullException . ThrowIfNull ( _httpContextAccessor . HttpContext ) ;
64
+ if ( _httpContextAccessor . HttpContext is null )
65
+ {
66
+ return null ;
67
+ }
68
+
65
69
return _options . Value . TenantIdFactory . Invoke ( _httpContextAccessor . HttpContext ) ;
66
70
}
67
71
68
- public TenantInfo GetTenantInfo ( )
72
+ public TenantInfo ? GetTenantInfo ( )
69
73
{
70
- ArgumentNullException . ThrowIfNull ( _httpContextAccessor . HttpContext ) ;
74
+ if ( _httpContextAccessor . HttpContext is null )
75
+ {
76
+ return null ;
77
+ }
78
+
71
79
return _options . Value . TenantInfoFactory . Invoke ( _httpContextAccessor . HttpContext ) ;
72
80
}
73
- #nullable restore
74
81
}
Original file line number Diff line number Diff line change @@ -38,7 +38,11 @@ IOptions<HttpContextUserIdProviderOptions> options
38
38
39
39
public string ? GetUserId ( )
40
40
{
41
- ArgumentNullException . ThrowIfNull ( _httpContextAccessor . HttpContext ) ;
41
+ if ( _httpContextAccessor . HttpContext is null )
42
+ {
43
+ return null ;
44
+ }
45
+
42
46
return _userIdFactory . Invoke ( _httpContextAccessor . HttpContext ) ;
43
47
}
44
48
}
You can’t perform that action at this time.
0 commit comments