29 |
if (tc == null) { return new List<string>(); } |
if (tc == null) { return new List<string>(); } |
30 |
else { return GetMessagesFromThreadContextStack(tc); } |
else { return GetMessagesFromThreadContextStack(tc); } |
31 |
} |
} |
32 |
catch { return new List<string>(); } |
catch { return new List<string>(); } |
33 |
} |
} |
34 |
public static List<string> GetMessagesFromThreadContextStack(ThreadContextStack rawTCS) |
public static List<string> GetMessagesFromThreadContextStack(ThreadContextStack rawTCS) |
35 |
{ |
{ |
36 |
ThreadContextStack oldrawTCS = rawTCS; |
Type t = typeof(ThreadContextStack); |
37 |
List<string> stack_objects = new List<string>(); |
//ConstructorInfo ci = t.GetConstructor(BindingFlags.NonPublic | BindingFlags.Instance, null, new Type[0], null); |
38 |
|
//ThreadContextStack tmpRawTCS = null; |
39 |
ThreadContextStack context = (rawTCS as ThreadContextStack); |
//tmpRawTCS = (ThreadContextStack)ci.Invoke(null); |
40 |
for (int i = 0; i < context.Count; i++) |
List<string> stObjects = new List<string>(); |
41 |
{ |
ThreadContextStack context = (rawTCS as ThreadContextStack); |
42 |
Type t = typeof(ThreadContextStack); |
for (int i = 0; i < context.Count; i++) |
43 |
MethodInfo mi = t.GetMethod("GetFullMessage", BindingFlags.NonPublic | BindingFlags.Instance); |
{ |
44 |
string message = mi.Invoke(context, null).ToString(); |
MethodInfo mi = t.GetMethod("GetFullMessage", BindingFlags.NonPublic | BindingFlags.Instance); |
45 |
stack_objects.Add(message); |
string message = mi.Invoke(context, null).ToString(); |
46 |
context.Pop(); |
stObjects.Add(message); |
47 |
} |
context.Pop(); |
48 |
rawTCS = oldrawTCS; |
} |
49 |
return stack_objects; |
stObjects.Reverse(); |
50 |
|
rawTCS.Clear(); |
51 |
|
// push the popped Context message back onto the original ContextStack |
52 |
|
foreach (string stObject in stObjects) { rawTCS.Push(stObject); } |
53 |
|
return stObjects; |
54 |
} |
} |
55 |
#endregion |
#endregion |
56 |
} |
} |