Esempio n. 1
0
        /// <summary>Updates the number of references to i - used by incrementRefs and decrementRefs </summary>
        private int updateRefs(NuGenConnection c, int change)
        {
            System.Int32  hashCode     = (System.Int32)c.GetHashCode();
            System.Object o            = numRefs[hashCode];
            int           existingRefs = 0;

            if (o != null)
            {
                existingRefs = ((System.Int32)o);
            }
            System.Int32 newRefs = (System.Int32)(existingRefs + change);
            numRefs[hashCode] = newRefs;
            return(newRefs);
        }
Esempio n. 2
0
        /// <summary>Closes the given connection & removes from hash - to be called when there are 0 references to it </summary>
        private void  close(NuGenConnection c)
        {
            c.close();

            //remove from "connections"
            System.Collections.IEnumerator keys = new SupportClass.HashSetSupport(connections.Keys).GetEnumerator();
            bool removed = false;

            while (keys.MoveNext() && !removed)
            {
                System.Object key = keys.Current;
                System.Object val = connections[key];
                if (val.GetHashCode() == c.GetHashCode())
                {
                    connections.Remove(key);
                    numRefs.Remove(key);
                    removed = true;
                }
            }
        }
		/// <summary>Updates the number of references to i - used by incrementRefs and decrementRefs </summary>
		private int updateRefs(NuGenConnection c, int change)
		{
			System.Int32 hashCode = (System.Int32) c.GetHashCode();
			System.Object o = numRefs[hashCode];
			int existingRefs = 0;
			if (o != null)
			{
				existingRefs = ((System.Int32) o);
			}
			System.Int32 newRefs = (System.Int32) (existingRefs + change);
			numRefs[hashCode] = newRefs;
			return newRefs;
		}
		/// <summary>Closes the given connection & removes from hash - to be called when there are 0 references to it </summary>
		private void  close(NuGenConnection c)
		{
			c.close();
			
			//remove from "connections"  
			System.Collections.IEnumerator keys = new SupportClass.HashSetSupport(connections.Keys).GetEnumerator();
			bool removed = false;
			while (keys.MoveNext() && !removed)
			{
				System.Object key = keys.Current;
				System.Object val = connections[key];
				if (val.GetHashCode() == c.GetHashCode())
				{
					connections.Remove(key);
					numRefs.Remove(key);
					removed = true;
				}
			}
		}