Skip to content

Commit a74861c

Browse files
authored
Merge pull request #133 from maddieclayton/asjob
Fix bool casting
2 parents 1889d5f + f66a113 commit a74861c

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/Common/AzureLongRunningJob.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -335,11 +335,11 @@ internal string GetShouldMethodFailureReaon(T cmdlet, ShouldMethodStreamItem met
335335
switch (methodType)
336336
{
337337
case ShouldMethodType.ShouldProcess:
338-
if (boundParameters != null && boundParameters.ContainsKey("Confirm") && (bool)boundParameters["Confirm"])
338+
if (boundParameters != null && boundParameters.ContainsKey("Confirm") && Convert.ToBoolean(boundParameters["Confirm"].ToString()))
339339
{
340340
result += Resources.ShouldProcessFailConfirm;
341341
}
342-
else if (boundParameters != null && boundParameters.ContainsKey("WhatIf") && (bool)boundParameters["WhatIf"])
342+
else if (boundParameters != null && boundParameters.ContainsKey("WhatIf") && Convert.ToBoolean(boundParameters["WhatIf"].ToString()))
343343
{
344344
result += Resources.ShouldProcessFailWhatIf;
345345
}
@@ -539,8 +539,8 @@ static string SafeGetVariableValue(PSCmdlet cmdlet, string name, string defaultV
539539
/// <returns>True if ShouldProcess does not need to be executed, false otherwise</returns>
540540
bool CanHandleShouldProcessLocally()
541541
{
542-
return !(_cmdlet.MyInvocation.BoundParameters.ContainsKey("Confirm") && (bool)_cmdlet.MyInvocation.BoundParameters["Confirm"]) &&
543-
!(_cmdlet.MyInvocation.BoundParameters.ContainsKey("WhatIf") && (bool)_cmdlet.MyInvocation.BoundParameters["WhatIf"]) &&
542+
return !(_cmdlet.MyInvocation.BoundParameters.ContainsKey("Confirm") && Convert.ToBoolean(_cmdlet.MyInvocation.BoundParameters["Confirm"].ToString())) &&
543+
!(_cmdlet.MyInvocation.BoundParameters.ContainsKey("WhatIf") && Convert.ToBoolean(_cmdlet.MyInvocation.BoundParameters["WhatIf"].ToString())) &&
544544
!_shouldConfirm;
545545
}
546546

@@ -554,7 +554,7 @@ protected void ThrowIfJobFailedOrCancelled()
554554
{
555555
if (IsFailedOrCancelled(JobStateInfo.State))
556556
{
557-
throw new LongRunningJobCancelledException("Azure Long running job is stopping, cnanot perform any action");
557+
throw new LongRunningJobCancelledException("Azure Long running job is stopping, cannot perform any action");
558558
}
559559
}
560560
}

0 commit comments

Comments
 (0)