Skip to content

Commit

Permalink
Merge pull request #359 from jibedoubleve/issue/324
Browse files Browse the repository at this point in the history
Issue/324
  • Loading branch information
jibedoubleve authored Nov 1, 2023
2 parents 11e34b5 + 7d1e416 commit 3540340
Show file tree
Hide file tree
Showing 11 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/Lanceur/Ui/Dialogs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public static class DialogMixin
{
#region Methods

public static bool AsBool(this ContentDialogResult result)
public static bool ToBool(this ContentDialogResult result)
{
return result switch
{
Expand Down
2 changes: 1 addition & 1 deletion src/Lanceur/Views/DoubloonsView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public DoubloonsView()
long.TryParse(interaction.Input, out value);

var result = await Dialogs.YesNoQuestion($"Do you want to delete {interaction.Input} {(value > 1 ? "aliases" : "alias")}?");
interaction.SetOutput(result.AsBool());
interaction.SetOutput(result.ToBool());
});

ViewModel.Activate.Execute().Subscribe();
Expand Down
2 changes: 1 addition & 1 deletion src/Lanceur/Views/InvalidAliasView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public InvalidAliasView()
long.TryParse(interaction.Input, out value);

var result = await Dialogs.YesNoQuestion($"Do you want to delete {interaction.Input} {(value > 1 ? "aliases" : "alias")}?");
interaction.SetOutput(result.AsBool());
interaction.SetOutput(result.ToBool());
});

ViewModel.Activate.Execute().Subscribe();
Expand Down
2 changes: 1 addition & 1 deletion src/Lanceur/Views/KeywordsView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public KeywordsView()
ViewModel.ConfirmRemove.RegisterHandler(async interaction =>
{
var result = await Dialogs.YesNoQuestion($"Do you want to delete alias '{interaction.Input}' and all its synonyms?");
interaction.SetOutput(result.AsBool());
interaction.SetOutput(result.ToBool());
});

this.OneWayBind(ViewModel, vm => vm.Aliases, v => v.Aliases.ItemsSource).DisposeWith(d);
Expand Down
2 changes: 1 addition & 1 deletion src/Lanceur/Views/PluginsView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public PluginsView()
{
var result =
await Dialogs.YesNoQuestion($"Do you want to uninstall the plugin '{interaction.Input}'?");
interaction.SetOutput(result.AsBool());
interaction.SetOutput(result.ToBool());
});
};
ViewModel.Activate.Execute().Subscribe();
Expand Down
2 changes: 1 addition & 1 deletion src/Lanceur/Views/SessionsView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public SessionsView()
ViewModel.ConfirmRemove.RegisterHandler(async interaction =>
{
var result = await Dialogs.YesNoQuestion($"Do you want to remove alias '{interaction.Input}'?");
interaction.SetOutput(result.AsBool());
interaction.SetOutput(result.ToBool());
});

this.OneWayBind(ViewModel, vm => vm.Sessions, v => v.CbSessions.ItemsSource).DisposeWith(d);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ internal abstract class AbstractOperationScheduler : IOperationScheduler

private static IEnumerable<IOperation> GetOperations(IEnumerable<OperationConfiguration> configurations)
{
return configurations.Select(cfg => cfg.AsOperation()).ToList();
return configurations.Select(cfg => cfg.ToOperation()).ToList();
}

protected IOperationScheduler AddOperations(IEnumerable<OperationConfiguration> operations, bool resetList = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@ public static class OperationMixin

#region Methods

public static IOperation AsOperation(this OperationConfiguration cfg)
public static IOperation ToOperation(this OperationConfiguration cfg)
{
var type =
(from t in Types
where t.FullName == cfg.Name
select t).FirstOrDefault();

if (type is null) throw new NotSupportedException($"Cannot find operation '{cfg.Name}'");

return (IOperation)Activator.CreateInstance(type, cfg.Parameters)!;
return type is null
? throw new NotSupportedException($"Cannot find operation '{cfg.Name}'")
: (IOperation)Activator.CreateInstance(type, cfg.Parameters)!;
}

#endregion Methods
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public async Task BeProcessed()
{
// ACT
var moveDirectory = OperationFactory.MoveDirectory(Source, Destination);
await moveDirectory.AsOperation()
await moveDirectory.ToOperation()
.ProcessAsync();

// ASSERT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public async Task BeProcessed()
var rmdir = OperationFactory.RemoveDirectory(directory);
Directory.Exists(directory).Should().BeTrue();

await rmdir.AsOperation()
await rmdir.ToOperation()
.ProcessAsync();

// ASSERT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public async Task BeProcessed()
{
// ACT
var unzipDir = OperationFactory.UnzipDirectory(ArchiveFile, Destination);
await unzipDir.AsOperation()
await unzipDir.ToOperation()
.ProcessAsync();

// ASSERT
Expand Down

0 comments on commit 3540340

Please sign in to comment.