Beispiel #1
0
        /// <summary>
        /// Evaluates the expression by calculating the value
        /// of the layout in the specified evaluation context.
        /// </summary>
        /// <param name="context">Evaluation context.</param>
        /// <returns>The value of the layout.</returns>
        protected override object EvaluateNode(LogEventInfo context)
        {
            if (_simpleLayout.IsSimpleStringText || !_simpleLayout.ThreadAgnostic)
            {
                return(_simpleLayout.Render(context));
            }

            var stringBuilder = System.Threading.Interlocked.Exchange(ref _fastObjectPool, null) ?? new StringBuilder();

            try
            {
                _simpleLayout.RenderAppendBuilder(context, stringBuilder);
                return(stringBuilder.ToString());
            }
            finally
            {
                stringBuilder.Length = 0;
                System.Threading.Interlocked.Exchange(ref _fastObjectPool, stringBuilder);
            }
        }