Skip to content

Commit 4bb49a7

Browse files
committed
Refactoring.
1 parent dd648b7 commit 4bb49a7

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Implementation/Lock/GetAzureResourceLockCmdlet.cs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,15 +79,20 @@ protected override void OnProcessRecord()
7979
/// </summary>
8080
private async Task<ResponseWithContinuation<JObject[]>> GetResources()
8181
{
82+
var response = new ResponseWithContinuation<JObject[]> { Value = new JObject[0] };
83+
8284
try
8385
{
8486
if (!string.IsNullOrWhiteSpace(this.LockName))
8587
{
8688
var resource = await this.GetResource().ConfigureAwait(continueOnCapturedContext: false);
87-
return new ResponseWithContinuation<JObject[]> { Value = resource.AsArray() };
88-
}
8989

90-
return await this.ListResourcesTypeCollection().ConfigureAwait(continueOnCapturedContext: false);
90+
response.Value = resource.AsArray();
91+
}
92+
else
93+
{
94+
response = await this.ListResourcesTypeCollection().ConfigureAwait(continueOnCapturedContext: false);
95+
}
9196
}
9297
catch (Exception ex)
9398
{
@@ -103,8 +108,7 @@ private async Task<ResponseWithContinuation<JObject[]>> GetResources()
103108
this.errors.Add(new ErrorRecord(ex, "ErrorGettingResourceLock", ErrorCategory.CloseError, null));
104109
}
105110

106-
return new ResponseWithContinuation<JObject[]> { Value = new JObject[0]
107-
};
111+
return response;
108112
}
109113

110114
/// <summary>

0 commit comments

Comments
 (0)