Skip to content

Commit 19c016d

Browse files
committed
CheckDisposed
1 parent 9aec427 commit 19c016d

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

WebApiClientCore.Extensions.OAuths/TokenProviders/TokenProvider.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ public TOptions GetOptionsValue<TOptions>()
5656
/// </summary>
5757
public void ClearToken()
5858
{
59+
this.CheckDisposed();
5960
using (this.asyncRoot.Lock())
6061
{
6162
this.token = null;
@@ -68,6 +69,7 @@ public void ClearToken()
6869
/// <returns></returns>
6970
public async Task<TokenResult> GetTokenAsync()
7071
{
72+
this.CheckDisposed();
7173
using (await this.asyncRoot.LockAsync().ConfigureAwait(false))
7274
{
7375
if (this.token == null)
@@ -125,5 +127,16 @@ public override string ToString()
125127
{
126128
return this.Name;
127129
}
130+
131+
/// <summary>
132+
/// 检查释放
133+
/// </summary>
134+
private void CheckDisposed()
135+
{
136+
if (this.IsDisposed == true)
137+
{
138+
throw new ObjectDisposedException(this.GetType().Name);
139+
}
140+
}
128141
}
129142
}

0 commit comments

Comments
 (0)