Ejemplo n.º 1
0
        /// <summary>
        /// Converts option's value to string to be displayed.
        /// </summary>
        /// <param name="value">The value of the option.</param>
        /// <returns>String representation of the option's value.</returns>
        private static string OptionValueToString(object value)
        {
            // lists:
            IList list = value as IList;

            if (list != null)
            {
                StringBuilder sb = new StringBuilder();
                for (int i = 0; i < list.Count; i++)
                {
                    if (list[i] != null)
                    {
                        if (i > 0)
                        {
                            sb.Append("; ");
                        }
                        sb.Append(list[i].ToString());
                    }
                }
                return(sb.ToString());
            }

            // convertible:
            IPhpConvertible conv = value as IPhpConvertible;

            if (conv != null)
            {
                return(conv.ToString());
            }

            Encoding encoding = value as Encoding;

            if (encoding != null)
            {
                return(encoding.WebName);
            }

            // others:
            return((value == null) ? String.Empty : value.ToString());
        }