예제 #1
0
 string INumericTC <char> .ToString(char c)
 {
     return(ObjectDisplay.FormatPrimitive(
                c,
                ObjectDisplayOptions.EscapeNonPrintableCharacters
                | ObjectDisplayOptions.UseQuotes
                ));
 }
예제 #2
0
        /// <summary>
        /// Returns a string representation of an object of primitive type.
        /// </summary>
        /// <param name="obj">A value to display as a string.</param>
        /// <param name="quoteStrings">Whether or not to quote string literals.</param>
        /// <param name="useHexadecimalNumbers">Whether or not to display integral literals in hexadecimal.</param>
        /// <returns>A string representation of an object of primitive type (or null if the type is not supported).</returns>
        /// <remarks>
        /// Handles <see cref="bool"/>, <see cref="string"/>, <see cref="char"/>, <see cref="sbyte"/>
        /// <see cref="byte"/>, <see cref="short"/>, <see cref="ushort"/>, <see cref="int"/>, <see cref="uint"/>,
        /// <see cref="long"/>, <see cref="ulong"/>, <see cref="double"/>, <see cref="float"/>, <see cref="decimal"/>,
        /// and <c>null</c>.
        /// </remarks>
        public static string FormatPrimitive(object obj, bool quoteStrings, bool useHexadecimalNumbers)
        {
            var options = ObjectDisplayOptions.EscapeNonPrintableCharacters;

            if (quoteStrings)
            {
                options |= ObjectDisplayOptions.UseQuotes;
            }
            if (useHexadecimalNumbers)
            {
                options |= ObjectDisplayOptions.UseHexadecimalNumbers;
            }
            return(ObjectDisplay.FormatPrimitive(obj, options));
        }
예제 #3
0
 /// <summary>
 /// Returns a string representation of an object of primitive type.
 /// </summary>
 /// <param name="obj">A value to display as a string.</param>
 /// <param name="quoteStrings">Whether or not to quote string literals.</param>
 /// <param name="useHexadecimalNumbers">Whether or not to display integral literals in hexadecimal.</param>
 /// <returns>A string representation of an object of primitive type (or null if the type is not supported).</returns>
 /// <remarks>
 /// Handles <see cref="bool"/>, <see cref="string"/>, <see cref="char"/>, <see cref="sbyte"/>
 /// <see cref="byte"/>, <see cref="short"/>, <see cref="ushort"/>, <see cref="int"/>, <see cref="uint"/>,
 /// <see cref="long"/>, <see cref="ulong"/>, <see cref="double"/>, <see cref="float"/>, <see cref="decimal"/>,
 /// and <c>null</c>.
 /// </remarks>
 public static string FormatPrimitive(object obj, bool quoteStrings, bool useHexadecimalNumbers)
 {
     return(ObjectDisplay.FormatPrimitive(obj, quoteStrings, useHexadecimalNumbers));
 }