/// <summary> Check if two entries have exactly the same name, type, and class.</summary> public override bool Equals(object obj) { if (obj is DNSEntry) { DNSEntry other = (DNSEntry)obj; return(name.Equals(other.name) && type == other.type && clazz == other.clazz); } return(false); }
/// <summary> Get a matching DNS entry from the table (using equals). /// Returns the entry that was found. /// </summary> public virtual DNSEntry get_Renamed(DNSEntry entry) { lock (this) { for (CacheNode node = find(entry.Name); node != null; node = node.Next) { if (node.Value.Equals(entry)) { return(node.Value); } } return(null); } }
/// <summary> Adds an entry to the table.</summary> public virtual void add(DNSEntry entry) { lock (this) { //logger.log("DNSCache.add("+entry.getName()+")"); CacheNode newValue = new CacheNode(entry); CacheNode node = (CacheNode)hashtable[entry.Name]; if (node == null) { hashtable[entry.Name] = newValue; } else { newValue.Next = node.Next; node.Next = newValue; } size++; } }
/// <summary> Remove a specific entry from the table. Returns true if the /// entry was found. /// </summary> public virtual bool remove(DNSEntry entry) { lock (this) { CacheNode node = (CacheNode)hashtable[entry.Name]; if (node != null) { if (node.Value == entry) { if (node.Next == null) { hashtable.Remove(entry.Name); } else { hashtable[entry.Name] = node.Next; } size--; return(true); } CacheNode previous = node; node = node.Next; while (node != null) { if (node.Value == entry) { previous.Next = node.Next; size--; return(true); } previous = node; node = node.Next; } ; } return(false); } }
public CacheNode(DNSEntry value) { this.value = value; }
/// <summary> Get a matching DNS entry from the table (using equals). /// Returns the entry that was found. /// </summary> public virtual DNSEntry get_Renamed(DNSEntry entry) { lock (this) { for (CacheNode node = find(entry.Name); node != null; node = node.Next) { if (node.Value.Equals(entry)) { return node.Value; } } return null; } }
/// <summary> Remove a specific entry from the table. Returns true if the /// entry was found. /// </summary> public virtual bool remove(DNSEntry entry) { lock (this) { CacheNode node = (CacheNode) hashtable[entry.Name]; if (node != null) { if (node.Value == entry) { if (node.Next == null) { hashtable.Remove(entry.Name); } else { hashtable[entry.Name] = node.Next; } size--; return true; } CacheNode previous = node; node = node.Next; while (node != null) { if (node.Value == entry) { previous.Next = node.Next; size--; return true; } previous = node; node = node.Next; } ; } return false; } }
/// <summary> Adds an entry to the table.</summary> public virtual void add(DNSEntry entry) { lock (this) { //logger.log("DNSCache.add("+entry.getName()+")"); CacheNode newValue = new CacheNode(entry); CacheNode node = (CacheNode) hashtable[entry.Name]; if (node == null) { hashtable[entry.Name] = newValue; } else { newValue.Next = node.Next; node.Next = newValue; } size++; } }