コード例 #1
0
        /// <summary>
        /// Initializes a new instance of the TargetMachine class.
        /// </summary>
        /// <param name="inputValue">
        /// Machine name.
        /// </param>
        public TargetMachine(string inputValue)
        {
            // Validate & throw custom exception
            IPAddress machineAddress;
            IPAddress defaultIpAdress = GetDefaultIp();

            if (string.IsNullOrWhiteSpace(inputValue))
            {
                SetMachineIPIfValid(defaultIpAdress, Constants.Localhost);
            }
            else if (IPAddress.TryParse(inputValue.Trim(), out machineAddress))
            {
                SetMachineIPIfValid(machineAddress, machineAddress.ToString());
            }
            else
            {
                SetMachineIPIfValid(GetIpFromName(inputValue), inputValue);
            }

            if (MachineIP.Equals(defaultIpAdress))
            {
                IsLocalMachine = true;
            }
            else
            {
                IsLocalMachine = false;
            }
        }
コード例 #2
0
 /// <summary>
 /// Initializes a new instance of the TargetMachine class.
 /// </summary>
 public TargetMachine()
 {
     IsLocalMachine = true;
     MachineIP      = GetDefaultIp();
     DisplayValue   = MachineIP.ToString();
 }