/// <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)); } }
/// <summary> /// Checks to see if the PropertyReaderFactory supports the tokenName. If not, returns a LiteralPropertyReader containing /// fullName /// </summary> private static PropertyReader CreateReaderOrLiteral(IPropertyReaderFactory propertyReaderFactory, Token token) { if (propertyReaderFactory.ContainsToken(token.TokenName)) { return propertyReaderFactory.Create(token); } else { return new LiteralPropertyReader(token.OriginalString); } }
/// <summary> /// Checks to see if the PropertyReaderFactory supports the tokenName. If not, returns a LiteralPropertyReader containing /// fullName /// </summary> private static PropertyReader CreateReaderOrLiteral(IPropertyReaderFactory propertyReaderFactory, Token token) { if (propertyReaderFactory.ContainsToken(token.TokenName)) { return(propertyReaderFactory.Create(token)); } else { return(new LiteralPropertyReader(token.OriginalString)); } }