Ejemplo n.º 1
0
        internal Trace(string callStack, string exceptionInfo)
        {
            Assumption.AssertNotNullOrEmpty(callStack, nameof(callStack));
            Assumption.AssertNotNullOrEmpty(exceptionInfo, nameof(exceptionInfo));

            string[]          entries = callStack.Split(new [] { Environment.NewLine, }, StringSplitOptions.None);
            List <DTOs.Frame> frames  = new List <Frame>(entries.Length);

            foreach (var entry in entries)
            {
                if (string.IsNullOrWhiteSpace(entry))
                {
                    continue;
                }

                frames.Add(new DTOs.Frame(entry));
            }
            if (frames.Count > 0)
            {
                this.Frames = frames.ToArray();
            }

            entries = exceptionInfo.Split(new [] { ": ", }, StringSplitOptions.None);
            DTOs.Exception ex = null;
            switch (entries.Length)
            {
            case 3:
                ex = new DTOs.Exception(entries[0], entries[1], entries[2]);
                break;

            case 2:
                ex = new DTOs.Exception(entries[0], entries[1]);
                break;

            case 1:
                ex = new DTOs.Exception(entries[0]);
                break;

            default:
                System.Diagnostics.Trace.WriteLine(
                    $"Unexpected exception info component/entry..."
                    );
                break;
            }
            if (ex != null)
            {
                this.Exception = ex;
            }
        }
Ejemplo n.º 2
0
        internal Trace(string callStack, string exceptionInfo)
        {
            Assumption.AssertNotNullOrEmpty(callStack, nameof(callStack));
            Assumption.AssertNotNullOrEmpty(exceptionInfo, nameof(exceptionInfo));

            string[]          entries = callStack.Split(new [] { Environment.NewLine, }, StringSplitOptions.None);
            List <DTOs.Frame> frames  = new List <Frame>(entries.Length);

            foreach (var entry in entries)
            {
                if (string.IsNullOrWhiteSpace(entry))
                {
                    continue;
                }

                frames.Add(new DTOs.Frame(entry));
            }
            this.Frames = frames.ToArray();

            entries = exceptionInfo.Split(new [] { ": ", }, StringSplitOptions.None);
            DTOs.Exception ex;
            switch (entries.Length)
            {
            case 3:
                ex = new DTOs.Exception(entries[0], entries[1], entries[2]);
                break;

            case 2:
                ex = new DTOs.Exception(entries[0], entries[1]);
                break;

            case 1:
                ex = new DTOs.Exception(entries[0]);
                break;

            default:
                traceSource.TraceEvent(TraceEventType.Warning, 0, $"Unexpected exception info component/entry...");
                ex = new DTOs.Exception("Default exception mock!");
                break;
            }
            this.Exception = ex;
        }