public TraceListenerCollection GetRuntimeObject() {
TraceListenerCollection listeners = new TraceListenerCollection();
bool _isDemanded = false;
foreach(ListenerElement element in this) {
// At some point, we need to pull out adding/removing the 'default' DefaultTraceListener
// code from here in favor of adding/not-adding after we load the config (in TraceSource
// and in static Trace)
if (!_isDemanded && !element._isAddedByDefault) {
// Do a full damand; This will disable partially trusted code from hooking up listeners
new SecurityPermission(SecurityPermissionFlag.UnmanagedCode).Demand();
_isDemanded = true;
}
listeners.Add(element.GetRuntimeObject());
}
return listeners;
}