/// <summary> Creates a SecurityController based on a XML serialised object. </summary>
/// <param name="el"> XML element that contains the serialized settings. </param>
/// <param name="parseExceptions"> Whether or not the the player exception list should be parsed.
/// If PlayerDB is not loaded, exceptions should NOT be parsed - otherwise they will not be preserved. </param>
public SecurityController([NotNull] XContainer el, bool parseExceptions)
{
if (el == null)
{
throw new ArgumentNullException("el");
}
XElement tempEl;
if ((tempEl = el.Element("minRank")) != null)
{
minRank = Rank.Parse(tempEl.Value);
}
if (parseExceptions)
{
foreach (XElement player in el.Elements("included"))
{
if (!Player.IsValidName(player.Value))
{
continue;
}
PlayerInfo info = PlayerDB.FindExact(player.Value);
if (info != null)
{
Include(info);
}
}
foreach (XElement player in el.Elements("excluded"))
{
if (!Player.IsValidName(player.Value))
{
continue;
}
PlayerInfo info = PlayerDB.FindExact(player.Value);
if (info != null)
{
Exclude(info);
}
}
}
else
{
rawExceptions = el.Elements("included").Union(el.Elements("excluded")).ToArray();
}
UpdatePlayerListCache();
}