Files
BeWoPlaner/Data/Access/DAOFactory.cs
Rene Evertz 71d1bfd2c2 Merge branch 'feature_rene_17_xrechnung'
# Conflicts:
#	Data/Data.csproj
#	Data/Entities/InvoiceBase.cs
#	Host/Web.Secrets.config.template
#	Host/Web.config
#	Service/ServiceBehavior/AdminServiceMessageInspector.cs
#	Service/ServiceContracts/IAdminService.cs
#	Shared/BeWoEntityEnums.cs
#	Shared/DataContracts/InvoiceBaseDC.cs
2025-09-27 19:41:52 +02:00

40 lines
1.8 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<GenericSearchDAO> _GenericSearchDAO = new Lazy<GenericSearchDAO>(() => new GenericSearchDAO());
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 GenericSearchDAO GenericSearchDAO => _GenericSearchDAO.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 LocalFileStorageDAO GetLocalFileStorage(string rootpath)
{
return new LocalFileStorageDAO(rootpath);
}
public static LocalTenantFileStorageDAO GetLocalTenantFileStorage(string rootpath)
{
return new LocalTenantFileStorageDAO(rootpath);
}
}
}