public void Add(DelimitedStringBuilder stringBuilder)
 {
     if (stringBuilder != null)
     {
         StringList.AddRange(stringBuilder.StringList);
     }
 }
Esempio n. 2
0
        private Tuple <String, String> ExceptionMessages(Exception exception)
        {
            DelimitedStringBuilder exceptionMessages    = new DelimitedStringBuilder();
            DelimitedStringBuilder exceptionStackTraces = new DelimitedStringBuilder();

            while (exception != null)
            {
                exceptionMessages.Add(exception.Message);
                exceptionStackTraces.Add(exception.StackTrace);

                exception = exception.InnerException;
            }
            return(new Tuple <String, String>(exceptionMessages.ToDelimitedString("<br/>"), exceptionStackTraces.ToDelimitedString("<br/>")));
        }
Esempio n. 3
0
        public override String ToString()
        {
            if (InternalValue.Count == 0)
            {
                return(String.Empty);
            }

            DelimitedStringBuilder builder = new DelimitedStringBuilder(InternalValue.Count);

            foreach (KeyValuePair <String, String> keyValue in InternalValue)
            {
                builder.Add(Pattern.FormatX(keyValue.Key, KeyValueDelimiter, keyValue.Value));
            }
            return(builder.ToDelimitedString(PairDelimiter));
        }
        public static String ToCsv(this IEnumerable <String> items)
        {
            if (items.IsEmpty())
            {
                return(String.Empty);
            }

            DelimitedStringBuilder csvBuilder = new DelimitedStringBuilder();

            foreach (String item in items)
            {
                csvBuilder.Add(ToCsvValue(item));
            }
            return(csvBuilder.ToDelimitedString(ValueLib.Comma.CharValue));
        }
Esempio n. 5
0
        public static String ToDescription(this Object value)
        {
            String result;

            if (value == null)
            {
                result = ValueLib.NullDescription.StringValue;
            }
            else if (value is DBNull)
            {
                result = ValueLib.DbNullDescription.StringValue;
            }
            else if (IsStateEmpty(value as IStateEmpty))
            {
                result = ValueLib.EmptyDescription.StringValue;
            }
            else if (value is IStateValid && !((IStateValid)value).IsValid)
            {
                result = ValueLib.InvalidDescription.StringValue;
            }
            else if (value is IStateAged && !((IStateAged)value).IsAged)
            {
                result = ValueLib.NotAgedDescription.StringValue;
            }
            else if (value is TimeSpan)
            {
                result = TimeSpanArticulator.Articulate((TimeSpan)value);
            }
            else if (value is Type)
            {
                result = ((Type)value).Name;
            }
            else if (value is IDictionary)
            {
                IDictionary            dictionary  = value as IDictionary;
                DelimitedStringBuilder innerResult = new DelimitedStringBuilder(dictionary.Count);
                foreach (Object key in dictionary.Keys)
                {
                    innerResult.Add("{0}{1}{2}", key.ToDescription(), ValueLib.KeyValueDelimiter.StringValue, dictionary[key].ToDescription());
                }
                result = innerResult.ToDelimitedString(ValueLib.ValueMark.CharValue);
            }
            else
            {
                result = value.ToString();
            }
            return(result);
        }
        public static String AsMessageOnly(this Exception exception)
        {
            var result = String.Empty;

            if (exception != null)
            {
                var message = new DelimitedStringBuilder();
                message.Add(exception.Message);

                if (exception.InnerException != null)
                {
                    message.Add(exception.InnerException.AsMessageOnly());
                }
                result = message.ToDelimitedString("  ");
            }
            return(result);
        }
        public static String ToLogString(this Exception exception)
        {
            var result = String.Empty;

            if (exception != null)
            {
                var message = new DelimitedStringBuilder();
                message.Add("Exception:{0}", exception.GetType().Name);
                message.Add("Message:{0}", exception.Message);

                if (exception.Source != null)
                {
                    message.Add("Source:" + exception.Source.Replace(ValueLib.EndOfLine.StringValue, ValueLib.Space.StringValue));
                }

                if (exception.Data.Count > 0)
                {
                    message.Add("Addition Information:");
                    message.Add(exception.Data.ToDescription());
                }

                if (!exception.HelpLink.IsEmpty())
                {
                    message.Add("Help Link:" + exception.HelpLink);
                }

                if (exception.StackTrace != null)
                {
                    message.Add("Stack Trace:" + exception.StackTrace);
                }

                if (exception.InnerException != null)
                {
                    message.Add("Inner " + exception.InnerException.ToLogString());
                }
                result = message.ToDelimitedString(ValueLib.Comma.CharValue);
            }
            return(result);
        }
Esempio n. 8
0
 public FixedResponse With(DelimitedStringBuilder messages)
 {
     return(FormatX(messages.ToDelimitedString(ValueLib.SemiColon.StringValue)));
 }
        public static String ToDelimitedString(this IList <String> list, String delimiter = ",")
        {
            DelimitedStringBuilder delimitedStringBuilder = new DelimitedStringBuilder(list);

            return(delimitedStringBuilder.ToDelimitedString(delimiter));
        }
        /// <summary>
        /// Convert a list into a human readable string delimited format.
        /// </summary>
        /// <typeparam name="T">Generic type that can be cast readily into a String.</typeparam>
        /// <param name="items">Items to convert into a String.</param>
        /// <param name="delimiter">Optional delimiter to use otherwise defaults to a comma followed by a space.</param>
        /// <returns>The list as a delimited string.</returns>
        public static String ToDelimitedString <T>(this IEnumerable <T> items, String delimiter = null)
        {
            DelimitedStringBuilder result = new DelimitedStringBuilder(items.Cast <String>());

            return(result.ToDelimitedString(delimiter ?? ValueLib.CommaSpace.StringValue));
        }