private static string ToHexInternal(long l, HexOptions options = DEFAULT) { CheckOptions(options); string s = l.ToString("X"); if (options.HasFlagFast(HexOptions.ZERO_PAD_HEX) && s.Length == 1) { s = StringConstants.ZERO + s; } if (options.HasFlagFast(HexOptions.PREFIX_HEX)) { s = StringConstants.HEX_PREFIX + s; } return(s); }
private static void CheckOptions(HexOptions options) { if (!options.HasFlagFast(HexOptions.HEX)) { string msg = String.Format("\"{0}\" must have the \"{1}\" flag set", nameof(options), nameof(HexOptions.HEX)); throw new ArgumentException(msg, nameof(options)); } }
private static string CreateStringElement(object value, HexOptions options) { return(options.HasFlagFast(HexOptions.HEX) ? Hex.TryCreateHex(value, options) : value.ToString()); }