public bool Load(string directory) { Wrapped.Clear(); String path = Path.Combine(directory, "DnsBans.xml"); if (File.Exists(path)) { FileStream stream = null; try { stream = File.Open(path, FileMode.Open, FileAccess.Read); XDocument document = XDocument.Load(stream); var records = from x in document.Root.Elements("pattern") select new Regex(x.Value); records.ForEach((record) => Wrapped.Add(record)); return(true); } catch { } finally { if (stream != null) { stream.Close(); stream.Dispose(); } } } return(false); }
public bool Load() { Wrapped.Clear(); String path = Path.Combine(Directories.Cache, "Records.xml"); if (File.Exists(path)) { FileStream stream = null; try { stream = File.Open(path, FileMode.Open, FileAccess.Read); XDocument document = XDocument.Load(stream); var records = from x in document.Root.Elements("Record") select new Record() { ClientId = new ClientId( Guid.Parse(x.Element("guid").Value), IPAddress.Parse(x.Element("address").Value)), Name = x.Element("name").Value, DnsName = x.Element("dnshost").Value, Trusted = bool.Parse(x.Element("trusted").Value), LastSeen = DateTime.FromBinary(long.Parse(x.Element("lastseen").Value)) }; records.ForEach((record) => Wrapped.Add(record)); this.admins = new Admin(server); this.bans = new Banned(server); this.dnsBans = new DnsBanned(); this.rBans = new RangeBanned(); return(true); } catch { } finally { if (stream != null) { stream.Close(); stream.Dispose(); } } } this.admins = new Admin(server); this.bans = new Banned(server); this.dnsBans = new DnsBanned(); this.rBans = new RangeBanned(); return(false); }
public bool Load(string directory) { Wrapped.Clear(); String path = Path.Combine(directory, "Passwords.xml"); if (File.Exists(path)) { FileStream stream = null; try { stream = File.Open(path, FileMode.Open, FileAccess.Read); XDocument document = XDocument.Load(stream); var records = from x in document.Root.Elements("Password") select new Password( Guid.Parse(x.Element("guid").Value), IPAddress.Parse(x.Element("address").Value), x.Element("string").Value, (AdminLevel)Int32.Parse(x.Element("level").Value)); records.ForEach((record) => Wrapped.Add(record)); return(true); } catch { } finally { if (stream != null) { stream.Close(); stream.Dispose(); } } } return(false); }
public void Clear() { Wrapped.Clear(); }
void ICollection <KeyValuePair <TKey, TValue> > .Clear() { Wrapped.Clear(); }
/// <summary> /// Removes all items from the <see cref="ICollection{T}"/>. /// </summary> /// /// <exception cref="NotSupportedException"> /// The <see cref="Wrapped"/> <see cref="IDictionary{TKey, TValue}"/> /// is read-only. /// </exception> public override void Clear() { Wrapped.Clear(); }