public static void AppendFormatLineIfNotNull(this RichTextBox builder, string format, uint arg) { if (arg != 0) { builder.AppendFormatLine(format, arg); } }
public static void AppendFormatLineIfNotNull(this RichTextBox builder, string format, string arg) { if (arg != string.Empty) { builder.AppendFormatLine(format, new object[] { arg }); } }
public static void AppendFormatLineIfNotZero(this TextBoxBase textbox, string format, float arg) { Contract.Requires(format != null); if (arg != 0.0f) textbox.AppendFormatLine(format, arg); }
public static void AppendFormatLineIfNotNullOrEmpty(this TextBoxBase textbox, string format, string arg) { Contract.Requires(format != null); if (!string.IsNullOrEmpty(arg)) textbox.AppendFormatLine(format, arg); }
//書式指定文字列を処理して追加 and 末尾に改行追加する。 //書式文字列が空文字列・スペース・Nullならインスタンスをそのまま返す。 //条件に一致しない場合はインスタンスをそのまま返す。 public static StringBuilder IfAppendFormatLine(this StringBuilder source, Func<bool> fnc, string format, params object[] args) { if (args.Any(obj => string.IsNullOrWhiteSpace(obj.ToString()))) return source; if (!fnc()) return source; return source.AppendFormatLine(format, args); }
public static void AppendFormatLineIfNotNull(this RichTextBox builder, string format, object arg) { if (arg.ToInt32() != 0) { builder.AppendFormatLine(format, arg); } }
/// <summary> /// Appends the string returned by processing a composite format string, which /// contains zero or more format items, followed by the default line terminator to /// the end of this instance if <paramref name="condition"/> is <see langword="true"/>. /// Each format item is replaced by the string representation of a corresponding /// argument in a parameter array using a specified format provider. /// </summary> /// <param name="source">The source <see cref="StringBuilder"/> object.</param> /// <param name="condition"><see langword="true"/> to append <paramref name="format"/>; /// otherwise, <see langword="false"/>.</param> /// <param name="provider">An object that supplies culture-specific formatting information.</param> /// <param name="format">A composite format string.</param> /// <param name="args">An array of objects to format.</param> /// <returns>A reference to <paramref name="source"/> with <paramref name="format"/> /// appended. Each format item in <paramref name="format"/> is replaced by the /// string representation of the corresponding object argument.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="format"/> or <paramref name="args"/> is <see langword="null"/>. /// </exception> /// <exception cref="System.FormatException"> /// <para><paramref name="format"/> is invalid.</para> /// <para>-or-</para> /// <para>The index of a format item is less than 0 (zero), or greater than or /// equal to the length of the args array.</para> /// </exception> /// <exception cref="System.ArgumentOutOfRangeException"> /// The length of the expanded string would exceed /// <see cref="p:StringBuilder.MaxCapacity"/>. /// </exception> public static StringBuilder AppendFormatLineIf(this StringBuilder source, bool condition, IFormatProvider provider, string format, params object[] args) { Contracts.Requires.NotNull(source, "source"); if (condition) { source.AppendFormatLine(provider, format, args); } return source; }
/// <overoads> /// <summary> /// Appends the string returned by processing a composite format string, which /// contains zero or more format items, followed by the default line terminator to /// the end of this instance. /// </summary> /// </overoads> /// <summary> /// Appends the string returned by processing a composite format string, which /// contains zero or more format items, followed by the default line terminator to /// the end of this instance. /// </summary> /// <param name="source">The source <see cref="StringBuilder"/> instance.</param> /// <param name="format">A composite format string.</param> /// <param name="args">An array of objects to format.</param> /// <returns>A reference to <paramref name="source"/> with <paramref name="format"/> /// appended. Each format item in <paramref name="format"/> is replaced by the /// string representation of the corresponding object argument.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="format"/> or <paramref name="args"/> is <see langword="null"/>. /// </exception> /// <exception cref="System.FormatException"> /// <para><paramref name="format"/> is invalid.</para> /// <para>-or-</para> /// <para>The index of a format item is less than 0 (zero), or greater than or /// equal to the length of the args array.</para> /// </exception> /// <exception cref="System.ArgumentOutOfRangeException"> /// The length of the expanded string would exceed /// <see cref="p:StringBuilder.MaxCapacity"/>. /// </exception> public static StringBuilder AppendFormatLine(this StringBuilder source, string format, params object[] args) { return source.AppendFormatLine(CultureInfo.CurrentCulture, format, args); }
public static void AppendFormatLineIfNotNull(this RichTextBox builder, string format, string arg) { Contract.Requires(format != null); if (arg != String.Empty) builder.AppendFormatLine(format, arg); }