コード例 #1
0
ファイル: DNSEntry.cs プロジェクト: rajeshwarn/mDNS
 /// <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);
 }
コード例 #2
0
ファイル: DNSCache.cs プロジェクト: rajeshwarn/mDNS
 /// <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);
     }
 }
コード例 #3
0
ファイル: DNSCache.cs プロジェクト: rajeshwarn/mDNS
 /// <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++;
     }
 }
コード例 #4
0
ファイル: DNSCache.cs プロジェクト: rajeshwarn/mDNS
        /// <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);
            }
        }
コード例 #5
0
ファイル: DNSCache.cs プロジェクト: rajeshwarn/mDNS
 public CacheNode(DNSEntry value)
 {
     this.value = value;
 }
コード例 #6
0
ファイル: DNSCache.cs プロジェクト: pisker/mDNS
		/// <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;
			}
		}
コード例 #7
0
ファイル: DNSCache.cs プロジェクト: pisker/mDNS
		/// <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;
			}
		}
コード例 #8
0
ファイル: DNSCache.cs プロジェクト: pisker/mDNS
		/// <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++;
			}
		}
コード例 #9
0
ファイル: DNSCache.cs プロジェクト: pisker/mDNS
			public CacheNode(DNSEntry value)
			{
				this.value = value;
			}