示例#1
0
        /// <summary>
        /// Converts an array value to a string of comma separated elements.
        /// </summary>
        /// <param name="value">The array value to convert.</param>
        /// <returns>A comma separated list of elements.</returns>
        private static String ConvertArrayToString(object value)
        {
            Type ltType = value.GetType();

            if (!ltType.IsArray)
            {
                throw new ArgumentException("must be an array type", "value");
            }

            StringBuilder lsbBuilder    = new StringBuilder();
            Type          ltElementType = ltType.GetElementType();
            bool          lbFirst       = true;

            foreach (Object loElement in (Array)value)
            {
                if (!lbFirst)
                {
                    lsbBuilder.Append(',');
                }
                else
                {
                    lbFirst = false;
                }

                lsbBuilder.Append(USENGConverter.ToString(ltElementType, loElement));
            }

            return(lsbBuilder.ToString());
        }
示例#2
0
 /// <summary>
 /// Converts a data type value of this type to a string.
 /// </summary>
 /// <param name="value">The value to convert.</param>
 /// <returns>The string representation of the value or null if value is null.</returns>
 public string ConvertToString(object value)
 {
     if (value == null)
     {
         return(null);
     }
     else
     if (value != null && value.GetType().IsArray)
     {
         return(ConvertArrayToString(value));
     }
     else
     {
         return(USENGConverter.ToString(BaseType, value));
     }
 }