Пример #1
0
        public void Render(TextWriter textWriter)
        {
            if (textWriter == null)
            {
                throw new ArgumentNullException(nameof(textWriter));
            }

            textWriter.Write(LineProtocolSyntax.EscapeName(_measurement));

            if (_tags != null)
            {
                foreach (KeyValuePair <string, string> tag in _tags.OrderBy(t => t.Key))
                {
                    if (string.IsNullOrEmpty(tag.Value))
                    {
                        continue;
                    }

                    textWriter.Write(',');
                    textWriter.Write(LineProtocolSyntax.EscapeName(tag.Key));
                    textWriter.Write('=');
                    textWriter.Write(LineProtocolSyntax.EscapeName(tag.Value));
                }
            }

            char fieldDelim = ' ';

            foreach (KeyValuePair <string, object> field in _fields)
            {
                textWriter.Write(fieldDelim);
                fieldDelim = ',';
                textWriter.Write(LineProtocolSyntax.EscapeName(field.Key));
                textWriter.Write('=');
                textWriter.Write(LineProtocolSyntax.FormatValue(field.Value));
            }

            if (_utcTimestamp != null)
            {
                textWriter.Write(' ');
                textWriter.Write(LineProtocolSyntax.FormatTimestamp(_utcTimestamp.Value));
            }
        }
Пример #2
0
 public void Can_escape_name(string nameOrKey, string expected)
 {
     LineProtocolSyntax.EscapeName(nameOrKey).Should().Be(expected);
 }