Files
BeWoPlaner/Data/Access/DAOFactory.cs
2025-06-02 11:16:35 +02:00

33 lines
1.5 KiB
C#

using BS.Shared.Interface;
using System;
namespace BeWo.Data.Access
{
public static class DAOFactory
{
/// https://csharpindepth.com/articles/singleton
/// -> Sixth version - using .NET 4's Lazy<T> type
///
/// Kleiner Fix bzgl Threadsafe
private static readonly Lazy<AdoDAO> _AdoDAO = new Lazy<AdoDAO>(() => new AdoDAO());
private static readonly Lazy<GenericDAO> _GenericDAO = new Lazy<GenericDAO>(() => new GenericDAO());
private static readonly Lazy<FinanceDAO> _FinanceDAO = new Lazy<FinanceDAO>(() => new FinanceDAO());
private static readonly Lazy<OrganisationDAO> _OrganisationDAO = new Lazy<OrganisationDAO>(() => new OrganisationDAO());
private static readonly Lazy<ScriptDAO> _ScriptDAO = new Lazy<ScriptDAO>(() => new ScriptDAO());
private static readonly Lazy<SearchDAO> _SearchDAO = new Lazy<SearchDAO>(() => new SearchDAO());
private static readonly Lazy<UserDAO> _UserDAO = new Lazy<UserDAO>(() => new UserDAO());
public static AdoDAO AdoDAO => _AdoDAO.Value;
public static GenericDAO GenericDAO => _GenericDAO.Value;
public static FinanceDAO FinanceDAO => _FinanceDAO.Value;
public static OrganisationDAO OrganisationDAO => _OrganisationDAO.Value;
public static ScriptDAO ScriptDAO => _ScriptDAO.Value;
public static SearchDAO SearchDAO => _SearchDAO.Value;
public static UserDAO UserDAO => _UserDAO.Value;
public static IFileStorageDAO GetLocalFileStorage(string rootpath)
{
return new LocalFileStorageDAO(rootpath);
}
}
}