Exemple #1
0
        public static LogRecordDataValue[] Combine(this LogRecordDataValue[] data0, LogRecordDataValue[] data1)
        {
            Contract.Requires <ArgumentNullException>(data0 != null);
            Contract.Requires <ArgumentNullException>(data1 != null);

            var arr = new LogRecordDataValue[data0.Length + data1.Length];

            data0.CopyTo(arr, 0);
            data1.CopyTo(arr, data0.Length);
            return(arr);
        }
Exemple #2
0
        public static LogRecordDataValue[] Combine(this LogRecordDataValue[] data0, LogRecordDataValue[] data1, LogRecordDataValue[] data2)
        {
            Contract.Requires <ArgumentNullException>(data0 != null);
            Contract.Requires <ArgumentNullException>(data1 != null);
            Contract.Requires <ArgumentNullException>(data2 != null);

            var bytesWritten = 0;
            var arr          = new LogRecordDataValue[data0.Length + data1.Length + data2.Length];

            data0.CopyTo(arr, bytesWritten);
            bytesWritten += data0.Length;
            data1.CopyTo(arr, bytesWritten);
            bytesWritten += data1.Length;
            data2.CopyTo(arr, bytesWritten);

            return(arr);
        }
Exemple #3
0
        public static LogRecordDataValue[] Combine(this LogRecordDataValue[] data0, params LogRecordDataValue[][] datas)
        {
            Contract.Requires <ArgumentNullException>(data0 != null);

            var datasLengthSum = datas.Sum(o => o.Length);

            var bytesWritten = 0;
            var arr          = new LogRecordDataValue[data0.Length + datasLengthSum];

            data0.CopyTo(arr, bytesWritten);
            bytesWritten += data0.Length;

            foreach (LogRecordDataValue[] data1 in datas)
            {
                data1.CopyTo(arr, bytesWritten);
                bytesWritten += data1.Length;
            }

            return(arr);
        }
Exemple #4
0
        private static LogRecordDataValue CreateDataValue(Exception exception)
        {
            if (exception.InnerException == null)
            {
                return(LogRecordDataValue.CreateException(exception.GetType().ToString(),
                                                          exception.Message,
                                                          LogRecordDataValue.CreateSimple("ExceptionSource", exception.Source),
                                                          LogRecordDataValue.CreateStackTrace("ExceptionStackTrace", exception.StackTrace)));
            }

            var inner      = exception;
            var exceptions = new List <Exception>();

            do
            {
                exceptions.Add(inner);
                inner = inner.InnerException;
            } while (inner != null);


            var lastException = exceptions[exceptions.Count - 1];
            var lastDataValue = LogRecordDataValue.CreateException(lastException.GetType().ToString(),
                                                                   lastException.Message,
                                                                   LogRecordDataValue.CreateSimple("ExceptionSource", lastException.Source),
                                                                   LogRecordDataValue.CreateStackTrace("ExceptionStackTrace", lastException.StackTrace));

            for (int i = exceptions.Count - 2; i >= 0; i--)
            {
                var ex        = exceptions[i];
                var dataValue = LogRecordDataValue.CreateException(ex.GetType().ToString(),
                                                                   ex.Message,
                                                                   LogRecordDataValue.CreateSimple("ExceptionSource", ex.Source),
                                                                   LogRecordDataValue.CreateStackTrace("ExceptionStackTrace", ex.StackTrace),
                                                                   lastDataValue);
                lastDataValue = dataValue;
            }

            return(lastDataValue);
        }