Code style fixes. Removal of unused code.

Signed-off-by: Konstantina Chremmou <konstantina.chremmou@citrix.com>
This commit is contained in:
Konstantina Chremmou 2022-04-11 20:52:25 +01:00
parent 558897740d
commit 9e8a8a77a5
4 changed files with 26 additions and 75 deletions

View File

@ -29,10 +29,9 @@
* SUCH DAMAGE. * SUCH DAMAGE.
*/ */
using System; using System.Drawing;
using System.Windows.Forms; using System.Windows.Forms;
using XenAdmin.XenSearch; using XenAdmin.XenSearch;
using System.Drawing;
using XenAPI; using XenAPI;
using XenCenterLib; using XenCenterLib;
@ -135,7 +134,7 @@ namespace XenAdmin.Core
} }
private static void PopulateMenuWith(ToolStripSplitButton button, LimitedStack<HistoryItem> history, private static void PopulateMenuWith(ToolStripSplitButton button, LimitedStack<HistoryItem> history,
HistoryNavigationDelegate historyNaviagtionDelegate) HistoryNavigationDelegate historyNavigationDelegate)
{ {
button.DropDownItems.Clear(); button.DropDownItems.Clear();
@ -143,14 +142,13 @@ namespace XenAdmin.Core
foreach (HistoryItem item in history) foreach (HistoryItem item in history)
{ {
int j = ++i; int j = ++i;
ToolStripMenuItem menuItem = new ToolStripMenuItem(); var menuItem = new ToolStripMenuItem
menuItem.Text = item.Name.EscapeAmpersands();
menuItem.Image = item.Image;
menuItem.ImageScaling = ToolStripItemImageScaling.None;
menuItem.Click += delegate(Object sender, EventArgs e)
{ {
historyNaviagtionDelegate(j); Text = item.Name.EscapeAmpersands(),
Image = item.Image,
ImageScaling = ToolStripItemImageScaling.None
}; };
menuItem.Click += (sender, e) => historyNavigationDelegate(j);
button.DropDownItems.Add(menuItem); button.DropDownItems.Add(menuItem);
} }
@ -207,13 +205,7 @@ namespace XenAdmin.Core
public override string Name => string.Format("{0}, ({1})", public override string Name => string.Format("{0}, ({1})",
o == null ? BrandManager.BrandConsole : Helpers.GetName(o), tab.Text); o == null ? BrandManager.BrandConsole : Helpers.GetName(o), tab.Text);
public override Image Image public override Image Image => o == null ? Images.GetImage16For(Icons.XenCenter) : Images.GetImage16For(o);
{
get
{
return o == null ? Images.GetImage16For(Icons.XenCenter) : Images.GetImage16For(o);
}
}
} }
internal class SearchHistoryItem : HistoryItem internal class SearchHistoryItem : HistoryItem
@ -244,21 +236,9 @@ namespace XenAdmin.Core
return search.GetHashCode(); return search.GetHashCode();
} }
public override string Name public override string Name => search.Name;
{
get
{
return search.Name;
}
}
public override Image Image public override Image Image => Images.GetImage16For(search);
{
get
{
return Images.GetImage16For(search);
}
}
} }
internal class ModifiedSearchHistoryItem : HistoryItem internal class ModifiedSearchHistoryItem : HistoryItem
@ -307,12 +287,6 @@ namespace XenAdmin.Core
public override string Name => string.Format("{0}, ({1})", public override string Name => string.Format("{0}, ({1})",
o == null ? BrandManager.BrandConsole : Helpers.GetName(o), Program.MainWindow.TabPageSearch.Text); o == null ? BrandManager.BrandConsole : Helpers.GetName(o), Program.MainWindow.TabPageSearch.Text);
public override Image Image public override Image Image => o == null ? Images.GetImage16For(Icons.XenCenter) : Images.GetImage16For(o);
{
get
{
return o == null ? Images.GetImage16For(Icons.XenCenter) : Images.GetImage16For(o);
}
}
} }
} }

View File

@ -120,34 +120,6 @@ namespace XenAdmin.Core
userAgent); userAgent);
} }
/// <summary>
/// It does exactly what CheckForUpdates(true) does, but this is sync and shows an ActionProgressDialog while running
/// </summary>
/// <returns>true if the action has succeeded</returns>
public static bool CheckForUpdatesSync(Control parentForProgressDialog)
{
if (Helpers.CommonCriteriaCertificationRelease)
return false;
var action = CreateDownloadUpdatesXmlAction(true, true, true);
action.Completed += actionCompleted;
if (CheckForUpdatesStarted != null)
CheckForUpdatesStarted();
if (parentForProgressDialog != null)
{
using (var dialog = new ActionProgressDialog(action, ProgressBarStyle.Marquee))
dialog.ShowDialog(parentForProgressDialog);
}
else
{
action.RunSync(action.Session);
}
return action.Succeeded;
}
private static void actionCompleted(ActionBase sender) private static void actionCompleted(ActionBase sender)
{ {
Program.AssertOffEventThread(); Program.AssertOffEventThread();

View File

@ -128,11 +128,14 @@ namespace XenCenterLib
{ {
byte[] saltBytes = GetSalt(); byte[] saltBytes = GetSalt();
using (var alg = new AesManaged()) using (var alg = new AesManaged
{
Key = keyBytes,
IV = saltBytes,
Padding = PaddingMode.PKCS7,//default value
Mode = CipherMode.CBC//default value
})
{ {
alg.Key = keyBytes;
alg.IV = saltBytes;
using (var ms = new MemoryStream()) using (var ms = new MemoryStream())
using (var cs = new CryptoStream(ms, alg.CreateEncryptor(), CryptoStreamMode.Write)) using (var cs = new CryptoStream(ms, alg.CreateEncryptor(), CryptoStreamMode.Write))
{ {
@ -161,13 +164,15 @@ namespace XenCenterLib
try try
{ {
using (var alg = new AesManaged()) using (var alg = new AesManaged
{ {
alg.IV = saltBytes; IV = saltBytes,
alg.Key = ComputeHash(key); Key = ComputeHash(key),
Padding = PaddingMode.PKCS7,//default value
Mode = CipherMode.CBC//default value
})
return DecryptString(cipherBytes, alg); return DecryptString(cipherBytes, alg);
} }
}
catch (Exception e) catch (Exception e)
{ {
log.Warn("Failed to decrypt. Trying legacy mode.", e); log.Warn("Failed to decrypt. Trying legacy mode.", e);