Exemple #1
0
        /// <summary>
        /// Gets full log event message including inner exceptions from the given exception
        /// </summary>
        public static string GetLogEventMessage(this Exception exception)
        {
            using (PooledObjectWrapper <StringBuilder> wrapper = Pools.StringBuilderPool.GetInstance())
            {
                var  instance = wrapper.Instance;
                bool first    = true;
                for (Exception currentException = exception; currentException != null; currentException = currentException.InnerException)
                {
                    if (first)
                    {
                        first = false;
                    }
                    else
                    {
                        instance.AppendLine(": ");
                    }

                    instance.Append(currentException.Message);
                }

                return(instance.ToString());
            }
        }
Exemple #2
0
        /// <summary>
        /// Describes this failure for the purpose of user-facing logging.
        /// The chain of inner failures is included in the message.
        /// </summary>
        public string DescribeIncludingInnerFailures()
        {
            using (PooledObjectWrapper <StringBuilder> wrapper = Pools.StringBuilderPool.GetInstance())
            {
                var  instance = wrapper.Instance;
                bool first    = true;
                for (Failure f = this; f != null; f = f.InnerFailure)
                {
                    if (first)
                    {
                        first = false;
                    }
                    else
                    {
                        instance.AppendLine(": ");
                    }

                    instance.Append(f.Describe());
                }

                return(instance.ToString());
            }
        }
Exemple #3
0
 /// <summary>
 /// Returns objects to the pool.
 /// </summary>
 /// <remarks>
 /// Search strategy is a simple linear probing which is chosen for it cache-friendliness.
 /// Note that PutInstance will try to store recycled objects close to the start thus statistically
 /// reducing how far we will typically search in GetInstance.
 /// </remarks>
 public void PutInstance(PooledObjectWrapper <T> wrapper) => PutInstance(wrapper.Instance);