Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ protected override void BeginProcessing()
ErrorRecord errorRecord = new ErrorRecord(exception, "CannotSpecifyIncludeTypeInformationAndNoTypeInformation", ErrorCategory.InvalidData, null);
this.ThrowTerminatingError(errorRecord);
}
if (this.MyInvocation.BoundParameters.ContainsKey("IncludeTypeInformation"))
if (this.MyInvocation.BoundParameters.ContainsKey(nameof(IncludeTypeInformation)))
{
NoTypeInformation = !IncludeTypeInformation;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ protected override void ProcessRecord()
// Enable debugging by preserving debug stop events.
debugger.UnhandledBreakpointMode = UnhandledBreakpointProcessingMode.Wait;

if (this.MyInvocation.BoundParameters.ContainsKey("BreakAll"))
if (this.MyInvocation.BoundParameters.ContainsKey(nameof(BreakAll)))
{
if (BreakAll)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ protected override void BeginProcessing()
// Throw out terminating error if this is the case.
if (IsModuleSpecified && IsFullyQualifiedModuleSpecified)
{
string errMsg = StringUtil.Format(SessionStateStrings.GetContent_TailAndHeadCannotCoexist, "Module", "FullyQualifiedModule");
string errMsg = StringUtil.Format(SessionStateStrings.GetContent_TailAndHeadCannotCoexist, nameof(Module), nameof(FullyQualifiedModule));
ErrorRecord error = new ErrorRecord(new InvalidOperationException(errMsg), "ModuleAndFullyQualifiedModuleCannotBeSpecifiedTogether", ErrorCategory.InvalidOperation, null);
ThrowTerminatingError(error);
}
Expand Down Expand Up @@ -275,7 +275,7 @@ protected override void BeginProcessing()
// Throw out terminating error if this is the case.
if (IsModuleSpecified && IsFullyQualifiedModuleSpecified)
{
string errMsg = StringUtil.Format(SessionStateStrings.GetContent_TailAndHeadCannotCoexist, "Module", "FullyQualifiedModule");
string errMsg = StringUtil.Format(SessionStateStrings.GetContent_TailAndHeadCannotCoexist, nameof(Module), nameof(FullyQualifiedModule));
ErrorRecord error = new ErrorRecord(new InvalidOperationException(errMsg), "ModuleAndFullyQualifiedModuleCannotBeSpecifiedTogether", ErrorCategory.InvalidOperation, null);
ThrowTerminatingError(error);
}
Expand Down Expand Up @@ -1643,10 +1643,10 @@ private PowerShell BuildPowerShellForGetCommand()
{
powerShell.AddParameter("Name", this.CommandName);
}
powerShell.AddParameter("Module", this.Module);
powerShell.AddParameter(nameof(Module), this.Module);
if (IsFullyQualifiedModuleSpecified)
{
powerShell.AddParameter("FullyQualifiedModule", this.FullyQualifiedModule);
powerShell.AddParameter(nameof(FullyQualifiedModule), this.FullyQualifiedModule);
}
powerShell.AddParameter("ArgumentList", this.ArgumentList);

Expand Down Expand Up @@ -2405,9 +2405,9 @@ private string GenerateReimportingOfModules()
{
StringBuilder result = new StringBuilder();

if (_invocationInfo.BoundParameters.ContainsKey("Module"))
if (_invocationInfo.BoundParameters.ContainsKey(nameof(Module)))
{
string[] moduleNames = (string[])_invocationInfo.BoundParameters["Module"];
string[] moduleNames = (string[])_invocationInfo.BoundParameters[nameof(Module)];
foreach (string moduleName in moduleNames)
{
result.AppendFormat(
Expand Down
12 changes: 6 additions & 6 deletions src/Microsoft.PowerShell.ScheduledJob/commands/NewJobTrigger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -272,22 +272,22 @@ private void CreateOnceTrigger()
{
TimeSpan? repInterval = null;
TimeSpan? repDuration = null;
if (MyInvocation.BoundParameters.ContainsKey("RepetitionInterval") || MyInvocation.BoundParameters.ContainsKey("RepetitionDuration") ||
MyInvocation.BoundParameters.ContainsKey("RepeatIndefinitely"))
if (MyInvocation.BoundParameters.ContainsKey(nameof(RepetitionInterval)) || MyInvocation.BoundParameters.ContainsKey(nameof(RepetitionDuration)) ||
MyInvocation.BoundParameters.ContainsKey(nameof(RepeatIndefinitely)))
{
if (MyInvocation.BoundParameters.ContainsKey("RepeatIndefinitely"))
if (MyInvocation.BoundParameters.ContainsKey(nameof(RepeatIndefinitely)))
{
if (MyInvocation.BoundParameters.ContainsKey("RepetitionDuration"))
if (MyInvocation.BoundParameters.ContainsKey(nameof(RepetitionDuration)))
{
throw new PSArgumentException(ScheduledJobErrorStrings.InvalidRepeatIndefinitelyParams);
}
if (!MyInvocation.BoundParameters.ContainsKey("RepetitionInterval"))
if (!MyInvocation.BoundParameters.ContainsKey(nameof(RepetitionInterval)))
{
throw new PSArgumentException(ScheduledJobErrorStrings.InvalidRepetitionRepeatParams);
}
_repDuration = TimeSpan.MaxValue;
}
else if (!MyInvocation.BoundParameters.ContainsKey("RepetitionInterval") || !MyInvocation.BoundParameters.ContainsKey("RepetitionDuration"))
else if (!MyInvocation.BoundParameters.ContainsKey(nameof(RepetitionInterval)) || !MyInvocation.BoundParameters.ContainsKey(nameof(RepetitionDuration)))
{
throw new PSArgumentException(ScheduledJobErrorStrings.InvalidRepetitionParams);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ protected override void ProcessRecord()
if (definition != null)
{
// Set the MaxCount value if available.
if (MyInvocation.BoundParameters.ContainsKey("MaxResultCount"))
if (MyInvocation.BoundParameters.ContainsKey(nameof(MaxResultCount)))
{
if (MaxResultCount < 1)
{
Expand All @@ -245,7 +245,7 @@ protected override void ProcessRecord()
{
// If RunEvery parameter is specified then create a job trigger for the definition that
// runs the job at the requested interval.
if (MyInvocation.BoundParameters.ContainsKey("RunEvery"))
if (MyInvocation.BoundParameters.ContainsKey(nameof(RunEvery)))
{
AddRepetitionJobTriggerToDefinition(
definition,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,13 +175,13 @@ public SwitchParameter StartIfIdle
protected override void BeginProcessing()
{
// Validate parameters.
if (MyInvocation.BoundParameters.ContainsKey("IdleTimeout") &&
if (MyInvocation.BoundParameters.ContainsKey(nameof(IdleTimeout)) &&
_idleTimeout < TimeSpan.Zero)
{
throw new PSArgumentException(ScheduledJobErrorStrings.InvalidIdleTimeout);
}

if (MyInvocation.BoundParameters.ContainsKey("IdleDuration") &&
if (MyInvocation.BoundParameters.ContainsKey(nameof(IdleDuration)) &&
_idleDuration < TimeSpan.Zero)
{
throw new PSArgumentException(ScheduledJobErrorStrings.InvalidIdleDuration);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ protected override void ProcessRecord()
// If RunEvery parameter is specified then create a job trigger for the definition that
// runs the job at the requested interval.
bool addedTrigger = false;
if (MyInvocation.BoundParameters.ContainsKey("RunEvery"))
if (MyInvocation.BoundParameters.ContainsKey(nameof(RunEvery)))
{
AddRepetitionJobTriggerToDefinition(
_definition,
Expand Down Expand Up @@ -340,7 +340,7 @@ private void UpdateDefinition()

UpdateJobInvocationInfo();

if (MyInvocation.BoundParameters.ContainsKey("MaxResultCount"))
if (MyInvocation.BoundParameters.ContainsKey(nameof(MaxResultCount)))
{
_definition.SetExecutionHistoryLength(MaxResultCount, false);
}
Expand Down Expand Up @@ -406,7 +406,7 @@ private Dictionary<string, object> UpdateParameters()
}

// RunAs32
if (MyInvocation.BoundParameters.ContainsKey("RunAs32"))
if (MyInvocation.BoundParameters.ContainsKey(nameof(RunAs32)))
{
if (newParameters.ContainsKey(ScheduledJobInvocationInfo.RunAs32Parameter))
{
Expand All @@ -419,7 +419,7 @@ private Dictionary<string, object> UpdateParameters()
}

// Authentication
if (MyInvocation.BoundParameters.ContainsKey("Authentication"))
if (MyInvocation.BoundParameters.ContainsKey(nameof(Authentication)))
{
if (newParameters.ContainsKey(ScheduledJobInvocationInfo.AuthenticationParameter))
{
Expand Down
Loading