Skip to content

Commit daa045f

Browse files
committed
Preserving existing behavior in RDFE cmdlets
1 parent 80539b7 commit daa045f

File tree

3 files changed

+42
-11
lines changed

3 files changed

+42
-11
lines changed

src/Common/Commands.Common/AzureDataCmdlet.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,5 +117,25 @@ protected override void PromptForDataCollectionProfileIfNotExists()
117117
protected override void InitializeQosEvent()
118118
{
119119
}
120+
121+
/// <summary>
122+
/// Guards execution of the given action using ShouldProcess and ShouldContinue. The optional
123+
/// useSHouldContinue predicate determines whether SHouldContinue should be called for this
124+
/// particular action (e.g. a resource is being overwritten). By default, both
125+
/// ShouldProcess and ShouldContinue will be executed. Cmdlets that use this method overload
126+
/// must have a force parameter.
127+
/// </summary>
128+
/// <param name="force">Do not ask for confirmation</param>
129+
/// <param name="continueMessage">Message to describe the action</param>
130+
/// <param name="processMessage">Message to prompt after the active is performed.</param>
131+
/// <param name="target">The target name.</param>
132+
/// <param name="action">The action code</param>
133+
protected override void ConfirmAction(bool force, string continueMessage, string processMessage, string target,
134+
Action action)
135+
{
136+
ConfirmAction(force, continueMessage, processMessage, target, action, () => true);
137+
}
138+
139+
120140
}
121141
}

src/Common/Commands.Common/AzurePSCmdlet.cs

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -506,22 +506,35 @@ protected void LogQosEvent()
506506
}
507507

508508
/// <summary>
509-
/// Guards execution of the given action using ShouldProcess and ShouldContinue. The optional
510-
/// useSHouldContinue predicate determines whether SHouldContinue should be called for this
511-
/// particular action (e.g. a resource is being overwritten). By default, both
512-
/// ShouldProcess and ShouldContinue will be executed. Cmdlets that use this method overload
513-
/// must have a force parameter.
509+
/// Guards execution of the given action using ShouldProcess and ShouldContinue. This is a legacy
510+
/// version forcompatibility with older RDFE cmdlets.
514511
/// </summary>
515512
/// <param name="force">Do not ask for confirmation</param>
516513
/// <param name="continueMessage">Message to describe the action</param>
517514
/// <param name="processMessage">Message to prompt after the active is performed.</param>
518515
/// <param name="target">The target name.</param>
519516
/// <param name="action">The action code</param>
520-
protected void ConfirmAction(bool force, string continueMessage, string processMessage, string target,
517+
protected virtual void ConfirmAction(bool force, string continueMessage, string processMessage, string target,
521518
Action action)
522519
{
523-
ConfirmAction(force, continueMessage, processMessage, target, action, () => true);
520+
if (_qosEvent != null)
521+
{
522+
_qosEvent.PauseQoSTimer();
523+
}
524+
525+
if (force || ShouldContinue(continueMessage, ""))
526+
{
527+
if (ShouldProcess(target, processMessage))
528+
{
529+
if (_qosEvent != null)
530+
{
531+
_qosEvent.ResumeQosTimer();
532+
}
533+
action();
534+
}
535+
}
524536
}
537+
525538
/// <summary>
526539
/// Guards execution of the given action using ShouldProcess and ShouldContinue. The optional
527540
/// useSHouldContinue predicate determines whether SHouldContinue should be called for this
@@ -535,7 +548,7 @@ protected void ConfirmAction(bool force, string continueMessage, string processM
535548
/// <param name="target">The target name.</param>
536549
/// <param name="action">The action code</param>
537550
/// <param name="useShouldContinue">A predicate indicating whether ShouldContinue should be invoked for thsi action</param>
538-
protected void ConfirmAction(bool force, string continueMessage, string processMessage, string target, Action action, Func<bool> useShouldContinue)
551+
protected virtual void ConfirmAction(bool force, string continueMessage, string processMessage, string target, Action action, Func<bool> useShouldContinue)
539552
{
540553
if (null == useShouldContinue)
541554
{
@@ -567,7 +580,7 @@ protected void ConfirmAction(bool force, string continueMessage, string processM
567580
/// <param name="processMessage">The change being made to the resource</param>
568581
/// <param name="target">The resource that is being changed</param>
569582
/// <param name="action">The action to perform if confirmed</param>
570-
protected void ConfirmAction(string processMessage, string target, Action action)
583+
protected virtual void ConfirmAction(string processMessage, string target, Action action)
571584
{
572585
if (_qosEvent != null)
573586
{

src/ResourceManager/Common/Commands.ResourceManager.Common/AzureRMCmdlet.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,6 @@ protected void ConfirmResourceAction(string resourceId, bool force, string conti
146146
resourceId), action, promptForContinuation);
147147
}
148148

149-
150-
151149
protected override void SaveDataCollectionProfile()
152150
{
153151
if (_dataCollectionProfile == null)

0 commit comments

Comments
 (0)