public TraceListener GetRuntimeObject() { if (_runtimeObject != null) { return((TraceListener)_runtimeObject); } try { string className = TypeName; if (String.IsNullOrEmpty(className)) { // Look it up in SharedListeners Debug.Assert(_allowReferences, "_allowReferences must be true if type name is null"); if (_attributes != null || ElementInformation.Properties[_propFilter.Name].ValueOrigin == PropertyValueOrigin.SetHere || TraceOutputOptions != TraceOptions.None || !String.IsNullOrEmpty(InitData)) { throw new ConfigurationErrorsException(SR.GetString(SR.Reference_listener_cant_have_properties, Name)); } if (DiagnosticsConfiguration.SharedListeners == null) { throw new ConfigurationErrorsException(SR.GetString(SR.Reference_to_nonexistent_listener, Name)); } ListenerElement sharedListener = DiagnosticsConfiguration.SharedListeners[Name]; if (sharedListener == null) { throw new ConfigurationErrorsException(SR.GetString(SR.Reference_to_nonexistent_listener, Name)); } else { _runtimeObject = sharedListener.GetRuntimeObject(); return((TraceListener)_runtimeObject); } } else { // create a new one TraceListener newListener = (TraceListener)BaseGetRuntimeObject(); newListener.initializeData = InitData; newListener.Name = Name; newListener.SetAttributes(Attributes); newListener.TraceOutputOptions = TraceOutputOptions; if ((Filter != null) && (Filter.TypeName != null) && (Filter.TypeName.Length != 0)) { newListener.Filter = Filter.GetRuntimeObject(); } _runtimeObject = newListener; return(newListener); } } catch (ArgumentException e) { throw new ConfigurationErrorsException(SR.GetString(SR.Could_not_create_listener, Name), e); } }
public TraceListener GetRuntimeObject() { TraceListener listener2; if (base._runtimeObject != null) { return((TraceListener)base._runtimeObject); } try { if (string.IsNullOrEmpty(this.TypeName)) { if (((this._attributes != null) || (base.ElementInformation.Properties[_propFilter.Name].ValueOrigin == PropertyValueOrigin.SetHere)) || ((this.TraceOutputOptions != TraceOptions.None) || !string.IsNullOrEmpty(base.InitData))) { throw new ConfigurationErrorsException(System.SR.GetString("Reference_listener_cant_have_properties", new object[] { this.Name })); } if (DiagnosticsConfiguration.SharedListeners == null) { throw new ConfigurationErrorsException(System.SR.GetString("Reference_to_nonexistent_listener", new object[] { this.Name })); } ListenerElement element = DiagnosticsConfiguration.SharedListeners[this.Name]; if (element == null) { throw new ConfigurationErrorsException(System.SR.GetString("Reference_to_nonexistent_listener", new object[] { this.Name })); } base._runtimeObject = element.GetRuntimeObject(); return((TraceListener)base._runtimeObject); } TraceListener listener = (TraceListener)base.BaseGetRuntimeObject(); listener.initializeData = base.InitData; listener.Name = this.Name; listener.SetAttributes(this.Attributes); listener.TraceOutputOptions = this.TraceOutputOptions; if (((this.Filter != null) && (this.Filter.TypeName != null)) && (this.Filter.TypeName.Length != 0)) { listener.Filter = this.Filter.GetRuntimeObject(); } base._runtimeObject = listener; listener2 = listener; } catch (ArgumentException exception) { throw new ConfigurationErrorsException(System.SR.GetString("Could_not_create_listener", new object[] { this.Name }), exception); } return(listener2); }