Example #1
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);
        }
Example #2
0
 public static String ToDescription(this TimeSpan value, ETemporalGroupFlag accuracy)
 {
     Contract.Requires(value != null);
     return(TimeSpanArticulator.Articulate(value, accuracy));
 }
Example #3
0
 public static String ToDescription(this TimeSpan value)
 {
     Contract.Requires(value != null);
     return(TimeSpanArticulator.Articulate(value));
 }