using System; using System.Threading; using Umbraco.Core.Configuration; namespace Umbraco.Core.Persistence { /// /// 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 /// public sealed class DatabaseFactory { #region Singleton private static readonly Database _database = new Database(GlobalSettings.DbDsn); private static readonly Lazy lazy = new Lazy(() => new DatabaseFactory()); public static DatabaseFactory Current { get { return lazy.Value; } } private DatabaseFactory() { } #endregion /// /// Returns an instance of the PetaPoco database /// public Database Database { get { return _database; } } } }