Ejemplo n.º 1
0
        public void ToString_IFormattableNull_IsNull()
        {
            string act = TestStruct.ToString((IFormattable)null);
            string exp = null;

            Assert.AreEqual(exp, act);
        }
Ejemplo n.º 2
0
        public void ToString_IFormattableNull_IsNull()
        {
            IFormattable formatter = null;
            string       act       = TestStruct.ToString(formatter);
            string       exp       = null;

            Assert.AreEqual(exp, act);
        }
Ejemplo n.º 3
0
        /// <summary>Formats the object using the formatting arguments.</summary>
        /// <param name="formattable">
        /// The object to format.
        /// </param>
        /// <param name="arguments">
        /// The formatting arguments
        /// </param>
        /// <returns>
        /// A formatted string representing the object.
        /// </returns>
        public static string ToString(this IFormattable formattable, FormattingArguments arguments)
        {
            if (formattable == null)
            {
                return(null);
            }

            return(arguments.ToString(formattable));
        }
Ejemplo n.º 4
0
        /// <summary>Formats the object using the formatting arguments.</summary>
        /// <param name="formattable">
        /// The object to format.
        /// </param>
        /// <param name="arguments">
        /// The formatting arguments
        /// </param>
        /// <returns>
        /// A formatted string representing the object.
        /// </returns>
        public static string ToString(this IFormattable formattable, FormattingArguments arguments)
        {
            if (formattable == null)
            {
#pragma warning disable S2225
                // "ToString()" method should not return null
                // if the origin is null, it should not become string.Empty.
                return(null);

#pragma warning restore S2225
            }
            return(arguments.ToString(formattable));
        }