Files
Umbraco-CMS/src/Umbraco.Core/Persistence/DatabaseFactory.cs
Sebastiaan Janssen 6e0af6827e Fix weird merge issues
2013-01-31 14:35:18 -01:00

34 lines
989 B
C#

using System;
using System.Threading;
using Umbraco.Core.Configuration;
namespace Umbraco.Core.Persistence
{
/// <summary>
/// Provides access to the PetaPoco database as Singleton, so the database is created once in app lifecycle.
/// This is necessary for transactions to work properly
/// </summary>
public sealed class DatabaseFactory
{
#region Singleton
private static readonly Database _database = new Database(GlobalSettings.DbDsn);
private static readonly Lazy<DatabaseFactory> lazy = new Lazy<DatabaseFactory>(() => new DatabaseFactory());
public static DatabaseFactory Current { get { return lazy.Value; } }
private DatabaseFactory()
{
}
#endregion
/// <summary>
/// Returns an instance of the PetaPoco database
/// </summary>
public Database Database
{
get { return _database; }
}
}
}