/// <summary> /// Creates a new <see cref="SqlTraceListener"/> using the specified settings name /// </summary> /// <param name="settingsName">the name of the SqlTraceListener settings to use from configuration</param> public SqlTraceListener(string settingsName) : base(settingsName) { UkadcDiagnosticsSection ukadcDiagnosticsSection = UkadcDiagnosticsSection.ReadConfigSection(); SqlTraceListenerElement sqlTraceListenerElement = ukadcDiagnosticsSection.SqlTraceListeners[settingsName]; if (null == sqlTraceListenerElement) { throw new ConfigurationErrorsException( string.Format(CultureInfo.CurrentCulture, Resources.SqlTraceListenerConfigError, settingsName)); } string connectionString = ConfigurationManager.ConnectionStrings[sqlTraceListenerElement.ConnectionStringName].ConnectionString; // use default data adapter IDataAccessAdapter adapter = new SqlDataAccessAdapter(); adapter.Initialize( connectionString, sqlTraceListenerElement.CommandText, sqlTraceListenerElement.CommandType); DataAccessAdapter = adapter; IPropertyReaderFactory readerFactory = DefaultServiceLocator.GetService <IPropertyReaderFactory>(); foreach (ParameterElement param in sqlTraceListenerElement.Parameters) { PropertyReader propertyReader = readerFactory.Create(param); this.Parameters.Add( new SqlTraceParameter(param.Name, propertyReader, param.CallToString)); } }
private void Init() { if (!_initialised) { lock (_initlock) { if (!_initialised) { IPropertyReaderFactory readerFactory = DefaultServiceLocator.GetService <IPropertyReaderFactory>(); _initialised = true; _filePathReader = readerFactory.CreateCombinedReader(FilePath); _outputReader = readerFactory.CreateCombinedReader(Output); _writerCache = DefaultServiceLocator.GetService <IStreamWriterCache>(); try { SafeParseCleanInterval(); } // need to start the timer with the default value, even if this throws finally { Timer timer = new Timer(_cleanInterval.TotalMilliseconds); timer.Elapsed += new ElapsedEventHandler(timer_Elapsed); timer.Start(); } } } } }
static ProcessPropertyReader() { try { _process = Process.GetCurrentProcess(); _readOK = true; } catch (Exception exc) { _readOK = false; DefaultServiceLocator.GetService <IInternalLogger>().LogException(exc); } }
/// <summary> /// Creates a new instance of the <see cref="PropertyReaderFactory"/> /// </summary> /// <param name="loadConfig">Indicates whether to load any tokens in the AppDomain's configuration file</param> /// <param name="loadInternalTokens">Indicates whether to load the hard-coded internal token list</param> public PropertyReaderFactory(bool loadConfig, bool loadInternalTokens) { _combinedFactory = DefaultServiceLocator.GetService <ICombinedPropertyReaderFactory>(); if (loadInternalTokens) { AddInternalTokens(); } if (loadConfig) { LoadConfiguredTokens(); } }
/// <summary> /// Creates a propertyFilter using configuration, looking for a propertyFilter element with the specified name /// </summary> /// <param name="propertyFilterName">Name of the propertyFilter element to use for configuration</param> /// <exception cref="System.ArgumentNullException">Thrown if the propertyFilterName argument is null</exception> public PropertyFilter(string propertyFilterName) { if (string.IsNullOrEmpty(propertyFilterName)) { throw new ArgumentNullException("propertyFilterName"); } UkadcDiagnosticsSection section = UkadcDiagnosticsSection.ReadConfigSection(); PropertyFilterElement element = section.PropertyFilters[propertyFilterName]; if (element == null) { throw new ConfigurationErrorsException( string.Format(CultureInfo.CurrentCulture, Resources.PropertyFilterNotFound, propertyFilterName)); } PropertyReader = DefaultServiceLocator.GetService <IPropertyReaderFactory>().Create(element); Initialize(element.Value, element.Operation, PropertyReader, element.DefaultEvaluation); }
/// <summary> /// Configure the trace listener based on the named configuration section /// </summary> /// <param name="sectionName">The name of the config section</param> public SmtpTraceListener(string sectionName) : base("SmtpTraceListener") { UkadcDiagnosticsSection config = UkadcDiagnosticsSection.ReadConfigSection(); SmtpTraceListenerElement smtpTraceListenerElement = config.SmtpTraceListeners[sectionName]; if (null == smtpTraceListenerElement) { throw new ConfigurationErrorsException( string.Format(CultureInfo.CurrentCulture, Resources.SmtpTraceListenerConfigError, sectionName)); } InternalConfigure( DefaultServiceLocator.GetService <IPropertyReaderFactory>(), new SmtpService(), smtpTraceListenerElement.Host, smtpTraceListenerElement.Port, smtpTraceListenerElement.Username, smtpTraceListenerElement.Password, smtpTraceListenerElement.To, smtpTraceListenerElement.From, smtpTraceListenerElement.Subject, smtpTraceListenerElement.Body); }
/// <summary> /// Construct an instance of the trace listener /// </summary> /// <param name="name">The name of the trace listener</param> protected CustomTraceListener(string name) : base(name) { InternalLogger = DefaultServiceLocator.GetService <IInternalLogger>(); }
/// <summary> /// Construct the listener /// </summary> /// <param name="valueToken">A property reader</param> public ConsoleTraceListener(string valueToken) : base("OutputDebugStringTraceListener") { _propertyReader = DefaultServiceLocator.GetService <IPropertyReaderFactory>().CreateCombinedReader(valueToken); }
/// <summary> /// Creates a new instance of the DebuggerTraceListener class /// </summary> /// <param name="valueToken"></param> public DebuggerTraceListener(string valueToken) : base("DebuggerTraceListener") { _propertyReader = DefaultServiceLocator.GetService <IPropertyReaderFactory>().CreateCombinedReader(valueToken); }