/// <summary> /// Gets the DHCP request list string. /// </summary> /// <param name="dhcpOptionValue">The DHCP option value.</param> /// <param name="dhcpRequestListFormat">The DHCP request list format.</param> /// <param name="logger">The logger.</param> /// <returns>System.String.</returns> /// <autogeneratedoc /> public static string GetDhcpRequestListString(byte[] dhcpOptionValue, DhcpRequestListFormat dhcpRequestListFormat, IPureLogger logger = null) { StringBuilder sb = new StringBuilder(); foreach (var requestOption in dhcpOptionValue) { DhcpOption dhcpRequestOption = (DhcpOption)requestOption; switch (dhcpRequestListFormat) { case DhcpRequestListFormat.StringCommaSeparated: sb.Append($"{dhcpRequestOption.ToString()}, "); break; case DhcpRequestListFormat.StringNewlineSeparated: sb.Append($"{Environment.NewLine}{dhcpRequestOption.ToString()}"); break; case DhcpRequestListFormat.StringNewlineIndentedSeparated: sb.Append($"{Environment.NewLine} {dhcpRequestOption.ToString()}"); break; case DhcpRequestListFormat.HexValueCommaSeparated: sb.Append($"{ByteUtility.ByteToHex((byte) dhcpRequestOption)}, "); break; case DhcpRequestListFormat.HexValueSpaceSeparated: sb.Append($"{ByteUtility.ByteToHex((byte) dhcpRequestOption)} "); break; case DhcpRequestListFormat.HexValueDashSeparated: sb.Append($"{ByteUtility.ByteToHex((byte) dhcpRequestOption)}-"); break; case DhcpRequestListFormat.DecimalValueCommaSeparated: sb.Append($"{(byte) dhcpRequestOption}, "); break; case DhcpRequestListFormat.DecimalValueSpaceSeparated: sb.Append($"{(byte) dhcpRequestOption} "); break; } } // Remove trailing space if (sb.Length > 1) { if (sb[sb.Length - 1] == ' ' || sb[sb.Length - 1] == '-') { sb.Length--; } } // Remove trailing comma if (sb.Length > 1) { if (sb[sb.Length - 1] == ',') { sb.Length--; } } return(sb.ToString()); }