Ejemplo n.º 1
0
        public static string FormatCollection(IEnumerable data, bool escapeLineBreaks, out bool needsEscaping)
        {
            StringBuilder stringBuilder = new StringBuilder(256);

            needsEscaping = false;
            foreach (object data2 in data)
            {
                bool   flag;
                string text = LogRowFormatter.Format(data2, out flag);
                if (flag)
                {
                    needsEscaping = true;
                    Utf8Csv.EscapeAndAppendCollectionMember(stringBuilder, text, escapeLineBreaks);
                }
                else
                {
                    Utf8Csv.AppendCollectionMember(stringBuilder, text);
                }
            }
            if (stringBuilder.Length > 0)
            {
                stringBuilder.Remove(stringBuilder.Length - 1, 1);
            }
            return(stringBuilder.ToString());
        }
        public virtual string Set(Enum property, object value)
        {
            string text = null;

            try
            {
                if (this.VerifyIsDisposed())
                {
                    return(null);
                }
                if (value != null)
                {
                    text = LogRowFormatter.Format(value);
                }
                this.ActivityScope.SetProperty(property, text);
            }
            catch (ActivityContextException exception)
            {
                ExWatson.HandleException(new UnhandledExceptionEventArgs(exception, false), ReportOptions.None);
            }
            return(text);
        }
Ejemplo n.º 3
0
        protected virtual byte[] Encode(object data)
        {
            if (data == null)
            {
                return(null);
            }
            if (data is byte[])
            {
                return(this.EncodeBytes((byte[])data));
            }
            if (!(data is string) && data is IEnumerable)
            {
                return(this.EncodeCollection((IEnumerable)data));
            }
            bool   flag;
            string s = LogRowFormatter.Format(data, out flag);

            if (!flag)
            {
                return(Utf8Csv.Encode(s));
            }
            return(Utf8Csv.EncodeAndEscape(s, this.escapeLineBreaks));
        }
Ejemplo n.º 4
0
        public static string Format(object data)
        {
            bool flag;

            return(LogRowFormatter.Format(data, out flag));
        }