/// <summary> /// Adds an custom <see cref="ILogFormatter"/> instance of type <paramref name="customFormatterType"/> to the logging configuration. /// </summary> /// <param name="builder">Fluent interface extension point.</param> /// <param name="formatterName">Name of the <see cref="ILogFormatter"/> instance added to configuration.</param> /// <param name="customFormatterType">Concrete type of the custom <see cref="ILogFormatter"/> instance.</param> /// <param name="attributes">Attributes that should be passed to <paramref name="customFormatterType"/> when creating an instance.</param> /// <seealso cref="ILogFormatter"/> /// <seealso cref="CustomFormatterData"/> public static CustomFormatterBuilder CustomFormatterNamed(this FormatterBuilder builder, string formatterName, Type customFormatterType, NameValueCollection attributes) { if (string.IsNullOrEmpty(formatterName)) { throw new ArgumentException(Resources.ExceptionStringNullOrEmpty, "formatterName"); } if (customFormatterType == null) { throw new ArgumentNullException("customFormatterType"); } if (attributes == null) { throw new ArgumentNullException("attributes"); } if (!typeof(ILogFormatter).IsAssignableFrom(customFormatterType)) { throw new ArgumentException( string.Format( CultureInfo.CurrentCulture, Resources.ExceptionTypeMustImplementInterface, typeof(ILogFormatter)), "customFormatterType"); } return(new CustomFormatterBuilder(formatterName, customFormatterType, attributes)); }
/// <summary> /// Creates the configuration builder for a <see cref="TextFormatter"/> instance. /// </summary> /// <param name="builder">Fluent interface extension point.</param> /// <param name="formatterName">The name of the <see cref="TextFormatter"/> instance that will be added to configuration.</param> /// <seealso cref="TextFormatter"/> /// <seealso cref="TextFormatterData"/> public static TextFormatterBuilder TextFormatterNamed(this FormatterBuilder builder, string formatterName) { if (string.IsNullOrEmpty(formatterName)) { throw new ArgumentException(Resources.ExceptionStringNullOrEmpty, "formatterName"); } return(new TextFormatterBuilder(formatterName)); }
/// <summary> /// Creates the configuration builder for a <see cref="BinaryLogFormatter"/> instance. /// </summary> /// <param name="builder">Fluent interface extension point.</param> /// <param name="formatterName">The name of the <see cref="BinaryLogFormatter"/> instance that will be added to configuration.</param> /// <seealso cref="BinaryLogFormatter"/> /// <seealso cref="BinaryLogFormatterData"/> public static BinaryFormatterBuilder BinaryFormatterNamed(this FormatterBuilder builder, string formatterName) { if (formatterName == null) { throw new ArgumentException(Resources.ExceptionStringNullOrEmpty, "formatterName"); } return(new BinaryFormatterBuilder(formatterName)); }
/// <summary> /// Adds an custom <see cref="ILogFormatter"/> instance of type <typeparamref name="TCustomFormatter"/> to the logging configuration. /// </summary> /// <typeparam name="TCustomFormatter">Concrete type of the custom <see cref="ILogFormatter"/> instance.</typeparam> /// <param name="builder">Fluent interface extension point.</param> /// <param name="formatterName">Name of the <see cref="ILogFormatter"/> instance added to configuration.</param> /// <param name="attributes">Attributes that should be passed to <typeparamref name="TCustomFormatter"/> when creating an instance.</param> /// <seealso cref="ILogFormatter"/> /// <seealso cref="CustomFormatterData"/> public static CustomFormatterBuilder CustomFormatterNamed <TCustomFormatter>(this FormatterBuilder builder, string formatterName, NameValueCollection attributes) where TCustomFormatter : ILogFormatter { return(CustomFormatterNamed(builder, formatterName, typeof(TCustomFormatter), attributes)); }
/// <summary> /// Adds an custom <see cref="ILogFormatter"/> instance of type <paramref name="customFormatterType"/> to the logging configuration. /// </summary> /// <param name="builder">Fluent interface extension point.</param> /// <param name="formatterName">Name of the <see cref="ILogFormatter"/> instance added to configuration.</param> /// <param name="customFormatterType">Concrete type of the custom <see cref="ILogFormatter"/> instance.</param> /// <seealso cref="ILogFormatter"/> /// <seealso cref="CustomFormatterData"/> public static CustomFormatterBuilder CustomFormatterNamed(this FormatterBuilder builder, string formatterName, Type customFormatterType) { return(CustomFormatterNamed(builder, formatterName, customFormatterType, new NameValueCollection())); }
protected override void Arrange() { attributes.Add("key1", "value1"); attributes.Add("key2", "value2"); CustomFormatterBuilder = new FormatterBuilder().CustomFormatterNamed <MockLogFormatter>(CustomFormatterName, attributes); }
protected override void Arrange() { CustomFormatterBuilder = new FormatterBuilder().CustomFormatterNamed<MockLogFormatter>(CustomFormatterName); }