You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
|
|
|
|
namespace ZeroLevel.Services.Diagnostics
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Performs read of stack trace
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static class StackTraceReader
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Read current stack trace
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns>Result - enumerable of tuples as 'Type':'MethodName'</returns>
|
|
|
|
|
public static Tuple<string, string>[] ReadFrames()
|
|
|
|
|
{
|
|
|
|
|
var result = new List<Tuple<string, string>>();
|
|
|
|
|
var stackTrace = new StackTrace();
|
|
|
|
|
foreach (var frame in stackTrace.GetFrames() ?? Enumerable.Empty<StackFrame>())
|
|
|
|
|
{
|
|
|
|
|
var method = frame.GetMethod();
|
|
|
|
|
if (method != null && method.DeclaringType != null)
|
|
|
|
|
{
|
|
|
|
|
var type = method.DeclaringType.Name;
|
|
|
|
|
if (false == type.Equals("StackTraceReader", StringComparison.Ordinal))
|
|
|
|
|
{
|
|
|
|
|
result.Add(new Tuple<string, string>(type, method.Name));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return result.ToArray();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|