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

@ -38,7 +38,7 @@ namespace XenAdmin.Controls.CustomGridView
{
public class GridRow : IComparable<GridRow>
{
public Dictionary<string, GridItemBase> Items { get; }= new Dictionary<string, GridItemBase>();
public Dictionary<string, GridItemBase> Items { get; } = new Dictionary<string, GridItemBase>();
public List<GridRow> Rows { get; } = new List<GridRow>();
private Image Image => Expanded

View File

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

View File

@ -120,34 +120,6 @@ namespace XenAdmin.Core
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)
{
Program.AssertOffEventThread();

View File

@ -128,11 +128,14 @@ namespace XenCenterLib
{
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 cs = new CryptoStream(ms, alg.CreateEncryptor(), CryptoStreamMode.Write))
{
@ -161,12 +164,14 @@ namespace XenCenterLib
try
{
using (var alg = new AesManaged())
{
alg.IV = saltBytes;
alg.Key = ComputeHash(key);
using (var alg = new AesManaged
{
IV = saltBytes,
Key = ComputeHash(key),
Padding = PaddingMode.PKCS7,//default value
Mode = CipherMode.CBC//default value
})
return DecryptString(cipherBytes, alg);
}
}
catch (Exception e)
{