// Parse binary array in to constituent TxtRecord instances public int Parse(byte[] bytes, int index) { DnssdTxtRecord txtRecord; do { txtRecord = DnssdTxtRecord.Parse(bytes, ref index); if (txtRecord != null) { Append(txtRecord); } } while (txtRecord != null); return(index); }
public static string ToRecordString(DnssdTxtRecord txtRecord) { var builder = new StringBuilder(); foreach (var value in txtRecord.RecordBytes) { if (IsPrintable(value)) { builder.Append(Convert.ToChar(value)); } else { builder.Append($"\\x{value:X2}"); } } return(builder.ToString()); }
public static DnssdTxtRecord Parse(byte[] bytes, ref int index) { Guard.Against.Null(bytes, nameof(bytes)); Guard.Against.OutOfRange(index, nameof(index), 0, bytes.Length); if (index == bytes.Length) { return(null); } var length = bytes[index++]; var txtRecord = new DnssdTxtRecord(bytes.SubArray(index, length)); index += length; return(txtRecord); }
public void Append(DnssdTxtRecord record) { TxtRecords.Add(record); }