TraceUtils
Utility class to Get/Set TraceData
using System;
using System.Collections.Generic;
namespace DynamoServices
{
public static class TraceUtils
{
internal const string __TEMP_REVIT_TRACE_ID = "{0459D869-0C72-447F-96D8-08A7FB92214B}-REVIT";
[ThreadStatic]
private static Dictionary<string, string> _localStorageSlot;
internal static Dictionary<string, string> LocalStorageSlot {
get {
return _localStorageSlot ?? (_localStorageSlot = new Dictionary<string, string>());
}
set {
_localStorageSlot = value;
}
}
internal static List<string> TEMP_GetTraceKeys()
{
return new List<string> {
"{0459D869-0C72-447F-96D8-08A7FB92214B}-REVIT"
};
}
internal static void ClearTLSKey(string key)
{
LocalStorageSlot.Remove(key);
}
internal static void ClearAllKnownTLSKeys()
{
LocalStorageSlot.Clear();
}
public static string GetTraceData(string key)
{
if (!LocalStorageSlot.TryGetValue(key, out string value))
return null;
return value;
}
public static void SetTraceData(string key, string value)
{
if (LocalStorageSlot.ContainsKey(key))
LocalStorageSlot[key] = value;
else
LocalStorageSlot.Add(key, value);
}
}
}