private string ValidateComputerName(string computer, bool validateNewName) { IPAddress pAddress = null; string str; object obj; string str1 = null; if (computer.Equals(".", StringComparison.OrdinalIgnoreCase) || computer.Equals("localhost", StringComparison.OrdinalIgnoreCase) || computer.Equals(this._shortLocalMachineName, StringComparison.OrdinalIgnoreCase) || computer.Equals(this._fullLocalMachineName, StringComparison.OrdinalIgnoreCase)) { str1 = "localhost"; } else { bool flag = false; try { flag = IPAddress.TryParse(computer, out pAddress); } catch (Exception exception1) { Exception exception = exception1; CommandProcessorBase.CheckForSevereException(exception); } try { string hostName = Dns.GetHostEntry(computer).HostName; if (hostName.Equals(this._shortLocalMachineName, StringComparison.OrdinalIgnoreCase) || hostName.Equals(this._fullLocalMachineName, StringComparison.OrdinalIgnoreCase)) { str1 = "localhost"; } else { str1 = computer; } goto Label0; } catch (Exception exception3) { Exception exception2 = exception3; CommandProcessorBase.CheckForSevereException(exception2); if (flag) { str1 = computer; goto Label0; } else { object[] message = new object[2]; message[0] = computer; message[1] = exception2.Message; this.WriteErrorHelper(ComputerResources.CannotResolveComputerName, "AddressResolutionException", computer, ErrorCategory.InvalidArgument, false, message); str = null; } } return(str); } Label0: bool flag1 = str1.Equals("localhost", StringComparison.OrdinalIgnoreCase); if (!validateNewName || this._newName == null || ComputerWMIHelper.IsComputerNameValid(this._newName)) { return(str1); } else { AddComputerCommand addComputerCommand = this; string invalidNewName = ComputerResources.InvalidNewName; string str2 = "InvalidNewName"; string str3 = this._newName; int num = 5; int num1 = 0; object[] objArray = new object[2]; object[] objArray1 = objArray; int num2 = 0; if (flag1) { obj = this._shortLocalMachineName; } else { obj = str1; } objArray1[num2] = obj; objArray[1] = this._newName; addComputerCommand.WriteErrorHelper(invalidNewName, str2, str3, (ErrorCategory)num, num1 == 1 ? true : false, objArray); return(null); } }
private string ValidateComputerName() { IPAddress pAddress = null; string str; object obj; string str1 = null; if (this._computerName.Equals(".", StringComparison.OrdinalIgnoreCase) || this._computerName.Equals("localhost", StringComparison.OrdinalIgnoreCase) || this._computerName.Equals(this._shortLocalMachineName, StringComparison.OrdinalIgnoreCase) || this._computerName.Equals(this._fullLocalMachineName, StringComparison.OrdinalIgnoreCase)) { str1 = "localhost"; } else { bool flag = false; try { flag = IPAddress.TryParse(this._computerName, out pAddress); } catch (Exception exception1) { Exception exception = exception1; CommandProcessorBase.CheckForSevereException(exception); } try { string hostName = Dns.GetHostEntry(this._computerName).HostName; if (hostName.Equals(this._shortLocalMachineName, StringComparison.OrdinalIgnoreCase) || hostName.Equals(this._fullLocalMachineName, StringComparison.OrdinalIgnoreCase)) { str1 = "localhost"; } else { str1 = this._computerName; } goto Label0; } catch (Exception exception3) { Exception exception2 = exception3; CommandProcessorBase.CheckForSevereException(exception2); if (flag) { str1 = this._computerName; goto Label0; } else { string str2 = StringUtil.Format(ComputerResources.CannotResolveComputerName, this._computerName, exception2.Message); ErrorRecord errorRecord = new ErrorRecord(new InvalidOperationException(str2), "AddressResolutionException", ErrorCategory.InvalidArgument, this._computerName); base.WriteError(errorRecord); str = null; } } return(str); } Label0: bool flag1 = str1.Equals("localhost", StringComparison.OrdinalIgnoreCase); if (ComputerWMIHelper.IsComputerNameValid(this._newComputerName)) { return(str1); } else { string invalidNewName = ComputerResources.InvalidNewName; if (flag1) { obj = this._shortLocalMachineName; } else { obj = str1; } string str3 = StringUtil.Format(invalidNewName, obj, this._newComputerName); ErrorRecord errorRecord1 = new ErrorRecord(new InvalidOperationException(str3), "InvalidNewName", ErrorCategory.InvalidArgument, this._newComputerName); base.WriteError(errorRecord1); return(null); } }