|
@@ -15,7 +15,7 @@ namespace PRSDesktop
|
|
|
{
|
|
|
public class GlobalTokenGrid : DynamicGrid<SecurityDescriptor>
|
|
|
{
|
|
|
- private List<SecurityDescriptor> _descriptors;
|
|
|
+ private List<SecurityDescriptor>? _descriptors;
|
|
|
private static readonly BitmapImage defaultdisabled = PRSDesktop.Resources.disabled.Fade(0.25F).AsBitmapImage();
|
|
|
private static readonly BitmapImage defaulttick = PRSDesktop.Resources.tick.Fade(0.25F).AsBitmapImage();
|
|
|
private static readonly BitmapImage disabled = PRSDesktop.Resources.disabled.AsBitmapImage();
|
|
@@ -53,10 +53,10 @@ namespace PRSDesktop
|
|
|
|
|
|
public Guid GroupID { get; set; }
|
|
|
|
|
|
- private const String ENABLED_TOKENS = "Enabled";
|
|
|
- private const String DISABLED_TOKENS = "Disabled";
|
|
|
- private const String OVERRIDDEN_TOKENS = "Overridden";
|
|
|
- private const String DEFAULT_TOKENS = "Default";
|
|
|
+ private const string ENABLED_TOKENS = "Enabled";
|
|
|
+ private const string DISABLED_TOKENS = "Disabled";
|
|
|
+ private const string OVERRIDDEN_TOKENS = "Overridden";
|
|
|
+ private const string DEFAULT_TOKENS = "Default";
|
|
|
|
|
|
private static readonly string[] ENABLED_FILTERS = new[] { ENABLED_TOKENS, DISABLED_TOKENS };
|
|
|
private static readonly string[] OVERRIDDEN_FILTERS = new[] { OVERRIDDEN_TOKENS, DEFAULT_TOKENS };
|
|
@@ -64,10 +64,12 @@ namespace PRSDesktop
|
|
|
|
|
|
protected override DynamicGridColumns LoadColumns()
|
|
|
{
|
|
|
- var columns = new DynamicGridColumns();
|
|
|
- columns.Add(new DynamicGridColumn { ColumnName = "Group", Caption = "Group", Width = 150, Alignment = Alignment.MiddleCenter });
|
|
|
- columns.Add(new DynamicGridColumn { ColumnName = "Description", Caption = "Description", Width = 0, Alignment = Alignment.MiddleLeft });
|
|
|
- columns.Add(new DynamicGridColumn { ColumnName = "Category", Caption = "Applies To", Width = 200, Alignment = Alignment.MiddleCenter });
|
|
|
+ var columns = new DynamicGridColumns
|
|
|
+ {
|
|
|
+ new DynamicGridColumn { ColumnName = "Group", Caption = "Group", Width = 150, Alignment = Alignment.MiddleCenter },
|
|
|
+ new DynamicGridColumn { ColumnName = "Description", Caption = "Description", Width = 0, Alignment = Alignment.MiddleLeft },
|
|
|
+ new DynamicGridColumn { ColumnName = "Category", Caption = "Applies To", Width = 200, Alignment = Alignment.MiddleCenter }
|
|
|
+ };
|
|
|
|
|
|
ActionColumns.Clear();
|
|
|
|
|
@@ -184,7 +186,7 @@ namespace PRSDesktop
|
|
|
if (MatchFilter(filter, ALL_FILTERS))
|
|
|
return true;
|
|
|
|
|
|
- String descriptor = row.Get<SecurityDescriptor, String>(c => c.Descriptor);
|
|
|
+ string descriptor = row.Get<SecurityDescriptor, String>(c => c.Descriptor);
|
|
|
bool globaldefault = row.Get<SecurityDescriptor, bool>(c => c.Default);
|
|
|
|
|
|
if (!MatchFilter(filter, ENABLED_FILTERS))
|
|
@@ -235,10 +237,14 @@ namespace PRSDesktop
|
|
|
|
|
|
protected override SecurityDescriptor LoadItem(CoreRow row)
|
|
|
{
|
|
|
+ if(_descriptors is null)
|
|
|
+ {
|
|
|
+ throw new Exception("LoadItem() called before Reload()");
|
|
|
+ }
|
|
|
return _descriptors[row.Index];
|
|
|
}
|
|
|
|
|
|
- private CoreTable _table = null;
|
|
|
+ private CoreTable? _table = null;
|
|
|
|
|
|
protected override void Reload(Filters<SecurityDescriptor> criteria, Columns<SecurityDescriptor> columns,
|
|
|
ref SortOrder<SecurityDescriptor>? sort,
|
|
@@ -313,7 +319,7 @@ namespace PRSDesktop
|
|
|
|
|
|
|
|
|
|
|
|
- private BitmapImage GlobalImage(CoreRow row)
|
|
|
+ private BitmapImage? GlobalImage(CoreRow? row)
|
|
|
{
|
|
|
if (row == null)
|
|
|
return null;
|
|
@@ -324,7 +330,7 @@ namespace PRSDesktop
|
|
|
return row.Get<SecurityDescriptor, bool>(c => c.Default) ? defaulttick : defaultdisabled;
|
|
|
}
|
|
|
|
|
|
- private BitmapImage GroupImage(CoreRow row, Guid groupid)
|
|
|
+ private BitmapImage? GroupImage(CoreRow? row, Guid groupid)
|
|
|
{
|
|
|
if (row == null)
|
|
|
return null;
|
|
@@ -338,7 +344,7 @@ namespace PRSDesktop
|
|
|
: defaultdisabled;
|
|
|
}
|
|
|
|
|
|
- private BitmapImage UserImage(CoreRow row, Guid groupid, Guid userid)
|
|
|
+ private BitmapImage? UserImage(CoreRow? row, Guid groupid, Guid userid)
|
|
|
{
|
|
|
if (row == null)
|
|
|
return null;
|
|
@@ -398,7 +404,7 @@ namespace PRSDesktop
|
|
|
Reset
|
|
|
}
|
|
|
|
|
|
- private Dictionary<TokenAction, Tuple<String,String>> _tokennames = new Dictionary<TokenAction, Tuple<String,String>>()
|
|
|
+ private readonly Dictionary<TokenAction, Tuple<String,String>> _tokennames = new()
|
|
|
{
|
|
|
{ TokenAction.Enable, new("Enable", "Enabling") },
|
|
|
{ TokenAction.Disable, new("Disable", "Enabling") },
|
|
@@ -456,10 +462,10 @@ namespace PRSDesktop
|
|
|
resetchildren = confirm == MessageBoxResult.Yes;
|
|
|
}
|
|
|
|
|
|
- List<String> resetusers = new List<String>();
|
|
|
- List<String> resetgroups = new List<String>();
|
|
|
- List<String> resetglobals = new List<String>();
|
|
|
- List<GlobalSecurityToken> updates = new List<GlobalSecurityToken>();
|
|
|
+ var resetusers = new List<string>();
|
|
|
+ var resetgroups = new List<string>();
|
|
|
+ var resetglobals = new List<string>();
|
|
|
+ var updates = new List<GlobalSecurityToken>();
|
|
|
|
|
|
Progress.ShowModal($"{_tokennames[action].Item2} Tokens", (progress) =>
|
|
|
{
|
|
@@ -471,7 +477,7 @@ namespace PRSDesktop
|
|
|
progress.Report($"{_tokennames[action].Item2} Tokens ({(double)(i) * 100.0D / (double)rows.Count:F2}% complete)");
|
|
|
i++;
|
|
|
|
|
|
- String descriptor = row.Get<SecurityToken, String>(c => c.Descriptor);
|
|
|
+ string descriptor = row.Get<SecurityToken, String>(c => c.Descriptor);
|
|
|
bool defaultvalue = row.Get<SecurityDescriptor, bool>(c => c.Default);
|
|
|
bool desiredvalue = action switch
|
|
|
{
|
|
@@ -572,9 +578,9 @@ namespace PRSDesktop
|
|
|
resetchildren = confirm == MessageBoxResult.Yes;
|
|
|
}
|
|
|
|
|
|
- List<String> resetusers = new List<String>();
|
|
|
- List<String> resetgroups = new List<String>();
|
|
|
- List<SecurityToken> updates = new List<SecurityToken>();
|
|
|
+ var resetusers = new List<string>();
|
|
|
+ var resetgroups = new List<string>();
|
|
|
+ var updates = new List<SecurityToken>();
|
|
|
|
|
|
Progress.ShowModal($"{_tokennames[action].Item2} Tokens", (progress) =>
|
|
|
{
|
|
@@ -585,7 +591,7 @@ namespace PRSDesktop
|
|
|
progress.Report($"{_tokennames[action].Item2} Tokens ({(double)(i) * 100.0D / (double)rows.Count:F2}% complete)");
|
|
|
i++;
|
|
|
|
|
|
- String descriptor = row.Get<SecurityDescriptor, String>(c => c.Descriptor);
|
|
|
+ string descriptor = row.Get<SecurityDescriptor, String>(c => c.Descriptor);
|
|
|
bool globaldefault = row.Get<SecurityDescriptor, bool>(c => c.Default);
|
|
|
bool defaultvalue = GetGlobalOrDefault(descriptor, globaldefault);
|
|
|
var currentvalue = GetGroupOrDefault(descriptor, groupid, globaldefault);
|
|
@@ -646,8 +652,8 @@ namespace PRSDesktop
|
|
|
|
|
|
Progress.ShowModal($"{_tokennames[action].Item2} Tokens", (progress) =>
|
|
|
{
|
|
|
- List<String> resets = new List<String>();
|
|
|
- List<UserSecurityToken> updates = new List<UserSecurityToken>();
|
|
|
+ var resets = new List<string>();
|
|
|
+ var updates = new List<UserSecurityToken>();
|
|
|
|
|
|
int i = 1;
|
|
|
foreach (var row in rows)
|