Пример #1
0
        /// <summary>
        ///     Generates the message that would be logged without logging it.
        ///     Typically used for throwing an exception in warning-as-error cases.
        /// </summary>
        /// <returns>The message string.</returns>
        public virtual string GenerateMessage()
        {
            var extractor = new MessageExtractingLogger();

            _logAction(extractor, null);
            return(extractor.Message);
        }
Пример #2
0
        /// <summary>
        ///     Generates the message that would be logged without logging it.
        ///     Typically used for throwing an exception in warning-as-error cases.
        /// </summary>
        /// <param name="exception"> Optional exception associated with this event. </param>
        /// <returns> The message string. </returns>
        public virtual string GenerateMessage([CanBeNull] Exception exception = null)
        {
            var extractor = new MessageExtractingLogger();

            _logAction(extractor, exception);
            return(extractor.Message);
        }
Пример #3
0
        /// <summary>
        ///     Generates the message that would be logged without logging it.
        ///     Typically used for throwing an exception in warning-as-error cases.
        /// </summary>
        /// <param name="logAction">A delegate that will log the message to an <see cref="ILogger" />.</param>
        /// <returns>The message string.</returns>
        public virtual string GenerateMessage(Action <ILogger> logAction)
        {
            var extractor = new MessageExtractingLogger();

            logAction(extractor);
            return(extractor.Message);
        }
        /// <summary>
        ///     Generates the message that would be logged without logging it.
        ///     Typically used for throwing an exception in warning-as-error cases.
        /// </summary>
        /// <param name="arg"> The message argument. </param>
        /// <returns> The message string. </returns>
        public virtual string GenerateMessage(
            [CanBeNull] TParam arg)
        {
            var extractor = new MessageExtractingLogger();

            _logAction(extractor, arg, null);
            return(extractor.Message);
        }
        /// <summary>
        ///     Generates the message that would be logged without logging it.
        ///     Typically used for throwing an exception in warning-as-error cases.
        /// </summary>
        /// <param name="logAction"> A delegate that will log the message to an <see cref="ILogger" />. </param>
        /// <returns> The message string. </returns>
        public virtual string GenerateMessage([NotNull] Action <ILogger> logAction)
        {
            Check.NotNull(logAction, nameof(logAction));

            var extractor = new MessageExtractingLogger();

            logAction(extractor);
            return(extractor.Message);
        }
Пример #6
0
        /// <summary>
        ///     Generates the message that would be logged without logging it.
        ///     Typically used for throwing an exception in warning-as-error cases.
        /// </summary>
        /// <param name="arg1"> The first message argument. </param>
        /// <param name="arg2"> The second message argument. </param>
        /// <returns> The message string. </returns>
        public virtual string GenerateMessage(
            TParam1 arg1,
            TParam2 arg2)
        {
            var extractor = new MessageExtractingLogger();

            _logAction(extractor, arg1, arg2, null);
            return(extractor.Message);
        }
        public virtual string GenerateMessage(
            [CanBeNull] TParam1 arg1,
            [CanBeNull] TParam2 arg2,
            [CanBeNull] Exception?exception = null)
        {
            var extractor = new MessageExtractingLogger();

            _logAction(extractor, arg1, arg2, exception);
            return(extractor.Message);
        }
Пример #8
0
        /// <summary>
        ///     Generates the message that would be logged without logging it.
        ///     Typically used for throwing an exception in warning-as-error cases.
        /// </summary>
        /// <param name="arg1"> The first message argument. </param>
        /// <param name="arg2"> The second message argument. </param>
        /// <param name="arg3"> The third message argument. </param>
        /// <param name="arg4"> The fourth message argument. </param>
        /// <returns> The message string. </returns>
        public virtual string GenerateMessage(
            [CanBeNull] TParam1 arg1,
            [CanBeNull] TParam2 arg2,
            [CanBeNull] TParam3 arg3,
            [CanBeNull] TParam4 arg4)
        {
            var extractor = new MessageExtractingLogger();

            _logAction(extractor, arg1, arg2, arg3, arg4, null);
            return(extractor.Message);
        }
Пример #9
0
        /// <summary>
        ///     Generates the message that would be logged without logging it.
        ///     Typically used for throwing an exception in warning-as-error cases.
        /// </summary>
        /// <param name="arg1"> The first message argument. </param>
        /// <param name="arg2"> The second message argument. </param>
        /// <param name="arg3"> The third message argument. </param>
        /// <param name="arg4"> The fourth message argument. </param>
        /// <param name="arg5"> The fifth message argument. </param>
        /// <param name="arg6"> The sixth message argument. </param>
        /// <returns> The message string. </returns>
        public virtual string GenerateMessage(
            TParam1 arg1,
            TParam2 arg2,
            TParam3 arg3,
            TParam4 arg4,
            TParam5 arg5,
            TParam6 arg6)
        {
            var extractor = new MessageExtractingLogger();

            _logAction(extractor, arg1, arg2, arg3, arg4, arg5, arg6, null);
            return(extractor.Message);
        }