Ejemplo n.º 1
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="host"></param>
        /// <returns></returns>
        public bool addHost(Host host)
        {
            if (host == null)
            {
                throw new Exception("empty Host submitted");
            }

            bool success = true;
            foreach (Host h in hosts)   //check if host is already in list
            {
                if (h != null && h.hostIP == host.hostIP)
                {
                    success = false;
                }
            }
            if (success)
            {
                success = false;
                for (int i = 0; i < hosts.Length; i++)   //find a free host entry
                {
                    if (hosts[i] == null)
                    {
                        host.id = hostID;
                        hosts[i] = host;
                        success = true;
                        hostID++;
                        hostcount++;
                        break;
                    }
                    else if (i == hosts.Length)
                    {
                        throw new Exception("Limit reached");
                    }
                }
            }
            return success;
        }
Ejemplo n.º 2
0
 private void createTempHost()
 {
     // check if host changed
     if (this.host == null || this.host.hostIP != hostaddress1.Text && this.host.hostname != hostaddress1.Text)
     {
         if (hostaddress1.Text == "" || !(hostaddress1.TextLength > 2))
         {
             this.host = null;
         }
         else
         {
             this.host = new Host(hostaddress1.Text, hostID);
             buttonAddToList.Enabled = true;
         }
     }
 }
Ejemplo n.º 3
0
 internal Host[] getHosts()
 {
     Host[] hostarray = new Host[hostcount];
     int index = 0;
     foreach (Host host in hosts)
     {
         if (host == null)
         {
             // unused Host
         }
         else
         {
             hostarray[index] = host;
             index++;
         }
     }
     return hostarray;
 }