diff --git a/XenAdmin/Commands/Command.cs b/XenAdmin/Commands/Command.cs
index 55c2d4d23..d035466b5 100644
--- a/XenAdmin/Commands/Command.cs
+++ b/XenAdmin/Commands/Command.cs
@@ -112,20 +112,6 @@ namespace XenAdmin.Commands
{
}
- ///
- /// Gets a list of s from the specified s.
- ///
- protected static IEnumerable ConvertToSelection(IEnumerable xenObjects) where T : IXenObject
- {
- Util.ThrowIfParameterNull(xenObjects, "selection");
- List selection = new List();
- foreach (T xenObject in xenObjects)
- {
- selection.Add(new SelectedItem(xenObject));
- }
- return selection;
- }
-
///
/// Gets the current selection context for the Command.
///
diff --git a/XenAdmin/Commands/DestroySRCommand.cs b/XenAdmin/Commands/DestroySRCommand.cs
index 7bc09630a..6f4bd5c77 100644
--- a/XenAdmin/Commands/DestroySRCommand.cs
+++ b/XenAdmin/Commands/DestroySRCommand.cs
@@ -30,6 +30,7 @@
*/
using System.Collections.Generic;
+using System.Linq;
using XenAdmin.Actions;
using XenAdmin.Core;
using XenAPI;
@@ -51,18 +52,18 @@ namespace XenAdmin.Commands
{
}
- public DestroySRCommand(IMainWindow mainWindow, IEnumerable selection)
- : base(mainWindow, selection)
+ public DestroySRCommand(IMainWindow mainWindow, IEnumerable selectedItems)
+ : base(mainWindow, selectedItems)
{
}
- public DestroySRCommand(IMainWindow mainWindow, SR selection)
- : base(mainWindow, selection)
+ public DestroySRCommand(IMainWindow mainWindow, SR sr)
+ : base(mainWindow, sr)
{
}
- public DestroySRCommand(IMainWindow mainWindow, IEnumerable selection)
- : base(mainWindow, ConvertToSelection(selection))
+ public DestroySRCommand(IMainWindow mainWindow, IEnumerable srs)
+ : base(mainWindow, srs.Select(s => new SelectedItem(s)).ToList())
{
}
@@ -90,21 +91,9 @@ namespace XenAdmin.Commands
///
/// Gets the text for a menu item which launches this Command.
///
- public override string MenuText
- {
- get
- {
- return Messages.MAINWINDOW_DESTROY_SR;
- }
- }
+ public override string MenuText => Messages.MAINWINDOW_DESTROY_SR;
- protected override bool ConfirmationRequired
- {
- get
- {
- return true;
- }
- }
+ protected override bool ConfirmationRequired => true;
protected override string ConfirmationDialogText
{
@@ -163,20 +152,8 @@ namespace XenAdmin.Commands
return base.GetCantExecuteReasonCore(item);
}
- protected override string ConfirmationDialogYesButtonLabel
- {
- get
- {
- return Messages.MESSAGEBOX_DESTROY_SR_YES_BUTTON_LABEL;
- }
- }
+ protected override string ConfirmationDialogYesButtonLabel => Messages.MESSAGEBOX_DESTROY_SR_YES_BUTTON_LABEL;
- protected override bool ConfirmationDialogNoButtonSelected
- {
- get
- {
- return true;
- }
- }
+ protected override bool ConfirmationDialogNoButtonSelected => true;
}
}
diff --git a/XenAdmin/Commands/InstallToolsCommand.cs b/XenAdmin/Commands/InstallToolsCommand.cs
index 6a5e42b5c..b4f6d303f 100644
--- a/XenAdmin/Commands/InstallToolsCommand.cs
+++ b/XenAdmin/Commands/InstallToolsCommand.cs
@@ -62,7 +62,7 @@ namespace XenAdmin.Commands
}
public InstallToolsCommand(IMainWindow mainWindow, IEnumerable vms)
- : this(mainWindow, ConvertToSelection(vms))
+ : this(mainWindow, vms.Select(v => new SelectedItem(v)).ToList())
{
}
diff --git a/XenAdmin/Commands/RemoveHostFromPoolCommand.cs b/XenAdmin/Commands/RemoveHostFromPoolCommand.cs
index 445c2a15b..2ff55a9b0 100644
--- a/XenAdmin/Commands/RemoveHostFromPoolCommand.cs
+++ b/XenAdmin/Commands/RemoveHostFromPoolCommand.cs
@@ -66,7 +66,7 @@ namespace XenAdmin.Commands
}
public RemoveHostFromPoolCommand(IMainWindow mainWindow, IEnumerable hosts)
- : base(mainWindow, ConvertToSelection(hosts))
+ : base(mainWindow, hosts.Select(h => new SelectedItem(h)).ToList())
{
}
diff --git a/XenAdmin/Commands/RepairSRCommand.cs b/XenAdmin/Commands/RepairSRCommand.cs
index 081338c2d..f9d957a78 100644
--- a/XenAdmin/Commands/RepairSRCommand.cs
+++ b/XenAdmin/Commands/RepairSRCommand.cs
@@ -29,16 +29,12 @@
* SUCH DAMAGE.
*/
-using System;
using System.Collections.Generic;
-using System.Text;
-using XenAdmin.Core;
-using XenAPI;
-using System.Windows.Forms;
-using XenAdmin.Dialogs;
-using XenAdmin.Properties;
using System.Drawing;
-using System.Collections.ObjectModel;
+using System.Linq;
+using XenAdmin.Core;
+using XenAdmin.Dialogs;
+using XenAPI;
namespace XenAdmin.Commands
@@ -66,8 +62,8 @@ namespace XenAdmin.Commands
{
}
- public RepairSRCommand(IMainWindow mainWindow, IEnumerable selection)
- : base(mainWindow, ConvertToSelection(selection))
+ public RepairSRCommand(IMainWindow mainWindow, IEnumerable srs)
+ : base(mainWindow, srs.Select(s => new SelectedItem(s)).ToList())
{
}
@@ -94,28 +90,10 @@ namespace XenAdmin.Commands
return sr != null && sr.HasPBDs() && (sr.IsBroken() || !sr.MultipathAOK()) && !HelpersGUI.GetActionInProgress(sr) && sr.CanRepairAfterUpgradeFromLegacySL();
}
- public override Image MenuImage
- {
- get
- {
- return Images.StaticImages._000_StorageBroken_h32bit_16;
- }
- }
+ public override Image MenuImage => Images.StaticImages._000_StorageBroken_h32bit_16;
- public override string MenuText
- {
- get
- {
- return Messages.MAINWINDOW_REPAIR_SR;
- }
- }
+ public override string MenuText => Messages.MAINWINDOW_REPAIR_SR;
- public override string ContextMenuText
- {
- get
- {
- return Messages.MAINWINDOW_REPAIR_SR_CONTEXT_MENU;
- }
- }
+ public override string ContextMenuText => Messages.MAINWINDOW_REPAIR_SR_CONTEXT_MENU;
}
}