/// <summary> /// Returns a string representation of the field value. /// Useful when text dumping the contents of an event stream. /// </summary> /// <returns>The field value as a string</returns> public override string GetValueAsString(GetValueAsStringOptions options = GetValueAsStringOptions.NoOptions) { if (options.HasFlag(GetValueAsStringOptions.QuotesAroundStrings)) { return('"' + Value + '"'); } return(Value); }
/// <summary> /// Returns a string representation of the field, name and value. /// </summary> /// <returns>The field as a string</returns> public string ToString(GetValueAsStringOptions options) { string fieldName = FieldName; if (options.HasFlag(GetValueAsStringOptions.TrimBeginningUnderscore) && FieldName.StartsWith("_")) { fieldName = FieldName.Substring(1); } return(string.Intern(fieldName + " = " + this.GetValueAsString(options))); }
/// <summary> /// Returns a string representation of the field value. /// Useful when text dumping the contents of an event stream. /// </summary> /// <returns>The field value as a string</returns> public override string GetValueAsString(GetValueAsStringOptions options = GetValueAsStringOptions.NoOptions) { if (this.Value.Length == 0) { return("[]"); } if (Value[0] is CtfIntegerValue integerValue) { if (integerValue.Descriptor.Size == 8) { string encoding = integerValue.Descriptor.Encoding; if (StringComparer.Ordinal.Equals(encoding, "ASCII") || StringComparer.Ordinal.Equals(encoding, "UTF8")) { if (options.HasFlag(GetValueAsStringOptions.QuotesAroundStrings)) { return('"' + this.ReadAsString() + '"'); } return(this.ReadAsString()); } } } var sb = new StringBuilder("[ "); if (this.Value.Length > 0) { sb.Append("[0] = " + Value[0].GetValueAsString(options)); } for (uint x = 1; x < this.Value.Length; x++) { sb.Append($", [{x}] = " + Value[x].GetValueAsString(options)); } sb.Append(" ]"); return(string.Intern(sb.ToString())); }