- zetaenterpriselibrary-source.zip
- Caching
- Common
- Core
- Data
- Logging
- References
- Direct
- ICSharpCode.SharpZipLib.dll
- log4net.dll
- NUnit
- nunit.framework.dll
- nunit.framework.extensions.dll
- nunit.mocks.dll
- Externals
- ZetaLongPaths
- ZetaLongPaths.dll
- ZetaWebControlLibrary
- de
- ZetaWebControlLib.resources.dll
- ZetaWebControlLib.dll
- Tools
- UnitTests
- Properties
- Resources
- access.mdb
- Tests
- Common
- Data
- Logging
- Tools
- UnitTests.csproj
- Web
- Windows
- Base
- Common
- Configuration
- Controls
- Dialogs
- Misc
- Properties
- Windows.csproj
- Windows.snk
- ZetaEnterpriseLibrary.sln
- zetaenterpriselibrary-bin.zip
- de
- Zeta.EnterpriseLibrary.Common.resources.dll
- Zeta.EnterpriseLibrary.Data.resources.dll
- Zeta.EnterpriseLibrary.Logging.resources.dll
- Zeta.EnterpriseLibrary.Tools.resources.dll
- Zeta.EnterpriseLibrary.Web.resources.dll
- Zeta.EnterpriseLibrary.Windows.resources.dll
- ICSharpCode.SharpZipLib.dll
- log4net.dll
- Zeta.EnterpriseLibrary.Common.dll
- Zeta.EnterpriseLibrary.Common.pdb
- Zeta.EnterpriseLibrary.Data.dll
- Zeta.EnterpriseLibrary.Data.pdb
- Zeta.EnterpriseLibrary.Logging.dll
- Zeta.EnterpriseLibrary.Logging.pdb
- Zeta.EnterpriseLibrary.Tools.dll
- Zeta.EnterpriseLibrary.Tools.pdb
- Zeta.EnterpriseLibrary.Web.dll
- Zeta.EnterpriseLibrary.Web.pdb
- Zeta.EnterpriseLibrary.Windows.dll
- Zeta.EnterpriseLibrary.Windows.pdb
- ZetaLongPaths.dll
- ZetaLongPaths.pdb
|
namespace Zeta.EnterpriseLibrary.Data.Configuration
{
#region Using directives.
// ----------------------------------------------------------------------
using System.Configuration;
using Logging;
using Data;
// ----------------------------------------------------------------------
#endregion
/////////////////////////////////////////////////////////////////////////
/// <summary>
/// Central class for managing all configuration aspects of the library.
/// </summary>
public class LibraryConfiguration :
ConfigurationSection
{
#region Static routines.
// ------------------------------------------------------------------
/// <summary>
/// Singleton access to the library configuration.
/// </summary>
/// <value>The current.</value>
public static LibraryConfiguration Current
{
get
{
var result =
(LibraryConfiguration)
ConfigurationManager.GetSection(
@"zeta.enterpriselibrary.data" ) ?? new LibraryConfiguration();
return result;
}
}
// ------------------------------------------------------------------
#endregion
#region Public methods.
// ------------------------------------------------------------------
/// <summary>
/// Initializes a new instance of the <see cref="LibraryConfiguration"/> class.
/// </summary>
public LibraryConfiguration()
{
// Property initialization.
_properties =
new ConfigurationPropertyCollection
{
_connectionString,
_commandTimeoutSeconds,
_traceSqlEnabled
};
Initialize();
}
/// <summary>
/// Initialize this library.
/// Please ensure to call this function once at the very start of your
/// application, before doing any logging functions. A good place
/// would be inside the Main() method or GLOBAL.ASAX file.
/// </summary>
public void Initialize()
{
// Performs no operations but is here to provide a consistent
// interface.
}
/// <summary>
/// Gets the collection of properties.
/// </summary>
/// <value></value>
/// <returns>The <see cref="T:System.Configuration.ConfigurationPropertyCollection"></see>
/// of properties for the element.</returns>
protected override ConfigurationPropertyCollection Properties
{
get
{
return _properties;
}
}
// ------------------------------------------------------------------
#endregion
#region Public properties.
// ------------------------------------------------------------------
/// <summary>
/// The connection string to the database.
/// </summary>
/// <value>The connection string.</value>
public SmartConnectionString ConnectionString
{
get
{
return new SmartConnectionString(
(string)this[@"connectionString"] );
}
}
/// <summary>
/// The timeout for commands in seconds.
/// </summary>
/// <value>The command timeout seconds.</value>
public int CommandTimeoutSeconds
{
get
{
return (int)this[@"commandTimeoutSeconds"];
}
}
/// <summary>
/// Whether SQL-statements should be traced.
/// </summary>
/// <value><c>true</c> if [trace SQL enabled]; otherwise,
/// <c>false</c>.</value>
public bool TraceSqlEnabled
{
get
{
return
(bool)this[@"traceSqlEnabled"] &&
LogCentral.Current.IsLoggingEnabled( LogType.Info );
}
}
// ------------------------------------------------------------------
#endregion
#region Private variables.
// ------------------------------------------------------------------
private static ConfigurationPropertyCollection _properties;
private static readonly ConfigurationProperty _connectionString =
new ConfigurationProperty(
@"connectionString",
typeof( string ),
@"",
ConfigurationPropertyOptions.None );
private static readonly ConfigurationProperty _commandTimeoutSeconds =
new ConfigurationProperty(
@"commandTimeoutSeconds",
typeof( int ),
0,
ConfigurationPropertyOptions.None );
private static readonly ConfigurationProperty _traceSqlEnabled =
new ConfigurationProperty(
@"traceSqlEnabled",
typeof( bool ),
false,
ConfigurationPropertyOptions.None );
// ------------------------------------------------------------------
#endregion
}
/////////////////////////////////////////////////////////////////////////
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.