Skip to content

Commit

Permalink
Refactor parameter names and simplify iteration
Browse files Browse the repository at this point in the history
Changed parameter name `innerResult` to `methodInnerResult` in `OnInnerResultCompleted` method across multiple files in the `Caliburn.Micro` namespace for consistency:
- `ContinueResultDecorator.cs`
- `OverrideCancelResultDecorator.cs`
- `RescueResultDecorator.cs`
- `ResultDecoratorBase.cs`

Removed unnecessary variable `keys` in `HttpUtility.cs` within the `Caliburn.Micro.Maui` namespace, directly iterating over `this.Keys` in the `foreach` loop to simplify the code.

Closes #940
Closes #939
  • Loading branch information
vb2ae committed Dec 15, 2024
1 parent 664e243 commit b3e07e7
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 12 deletions.
6 changes: 3 additions & 3 deletions src/Caliburn.Micro.Core/ContinueResultDecorator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,17 @@ public ContinueResultDecorator(IResult result, Func<IResult> coroutine)
/// Called when the execution of the decorated result has completed.
/// </summary>
/// <param name="context">The context.</param>
/// <param name="innerResult">The decorated result.</param>
/// <param name="methodInnerResult">The decorated result.</param>
/// <param name="args">The <see cref="ResultCompletionEventArgs" /> instance containing the event data.</param>
protected override void OnInnerResultCompleted(CoroutineExecutionContext context, IResult innerResult, ResultCompletionEventArgs args)
protected override void OnInnerResultCompleted(CoroutineExecutionContext context, IResult methodInnerResult, ResultCompletionEventArgs args)
{
if (args.Error != null || !args.WasCancelled)
{
OnCompleted(new ResultCompletionEventArgs { Error = args.Error });
}
else
{
Log.Info(string.Format("Executing coroutine because {0} was cancelled.", innerResult.GetType().Name));
Log.Info(string.Format("Executing coroutine because {0} was cancelled.", methodInnerResult.GetType().Name));
Continue(context);
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/Caliburn.Micro.Core/OverrideCancelResultDecorator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ public OverrideCancelResultDecorator(IResult result)
/// Called when the execution of the decorated result has completed.
/// </summary>
/// <param name="context">The context.</param>
/// <param name="innerResult">The decorated result.</param>
/// <param name="methodInnerResult">The decorated result.</param>
/// <param name="args">The <see cref="ResultCompletionEventArgs" /> instance containing the event data.</param>
protected override void OnInnerResultCompleted(CoroutineExecutionContext context, IResult innerResult, ResultCompletionEventArgs args)
protected override void OnInnerResultCompleted(CoroutineExecutionContext context, IResult methodInnerResult, ResultCompletionEventArgs args)
{
if (args.WasCancelled)
{
Log.Info(string.Format("Overriding WasCancelled from {0}.", innerResult.GetType().Name));
Log.Info(string.Format("Overriding WasCancelled from {0}.", methodInnerResult.GetType().Name));
}

OnCompleted(new ResultCompletionEventArgs { Error = args.Error });
Expand Down
6 changes: 3 additions & 3 deletions src/Caliburn.Micro.Core/RescueResultDecorator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ public RescueResultDecorator(IResult result, Func<TException, IResult> coroutine
/// Called when the execution of the decorated result has completed.
/// </summary>
/// <param name="context">The context.</param>
/// <param name="innerResult">The decorated result.</param>
/// <param name="methodInnerResult">The decorated result.</param>
/// <param name="args">The <see cref="ResultCompletionEventArgs" /> instance containing the event data.</param>
protected override void OnInnerResultCompleted(CoroutineExecutionContext context, IResult innerResult, ResultCompletionEventArgs args)
protected override void OnInnerResultCompleted(CoroutineExecutionContext context, IResult methodInnerResult, ResultCompletionEventArgs args)
{
var error = args.Error as TException;
if (error == null)
Expand All @@ -40,7 +40,7 @@ protected override void OnInnerResultCompleted(CoroutineExecutionContext context
else
{
Log.Error(error);
Log.Info(string.Format("Executing coroutine because {0} threw an exception.", innerResult.GetType().Name));
Log.Info(string.Format("Executing coroutine because {0} threw an exception.", methodInnerResult.GetType().Name));
Rescue(context, error);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Caliburn.Micro.Core/ResultDecoratorBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ private void InnerResultCompleted(object sender, ResultCompletionEventArgs args)
/// Called when the execution of the decorated result has completed.
/// </summary>
/// <param name="context">The context.</param>
/// <param name="innerResult">The decorated result.</param>
/// <param name="methodInnerResult">The decorated result.</param>
/// <param name="args">The <see cref="ResultCompletionEventArgs"/> instance containing the event data.</param>
protected abstract void OnInnerResultCompleted(CoroutineExecutionContext context, IResult innerResult, ResultCompletionEventArgs args);
protected abstract void OnInnerResultCompleted(CoroutineExecutionContext context, IResult methodInnerResult, ResultCompletionEventArgs args);

/// <summary>
/// Occurs when execution has completed.
Expand Down
1 change: 0 additions & 1 deletion src/Caliburn.Micro.Platform/Platforms/Maui/HttpUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ public override string ToString()
if (count == 0)
return "";
StringBuilder sb = new StringBuilder();
var keys = this.Keys;
foreach (var key in this.Keys)
{
sb.AppendFormat("{0}={1}&", key, this[key]);
Expand Down

0 comments on commit b3e07e7

Please sign in to comment.