use singletons for data access and data access manager instances. make cstr injectable
This commit is contained in:
parent
e1b74a36a0
commit
1cd994b074
@ -20,6 +20,9 @@ namespace COA.EnterpriseServices.DataAccess
|
||||
s.AssembliesFromApplicationBaseDirectory();
|
||||
});
|
||||
|
||||
c.For(typeof(IDataAccess<>)).Singleton();
|
||||
c.For(typeof(DataAccessManager<>)).Singleton();
|
||||
|
||||
c.For<ClientHelper>().Singleton();
|
||||
c.For<CreditorHelper>().Singleton();
|
||||
});
|
||||
|
@ -8,18 +8,13 @@ namespace COA.EnterpriseServices.DataAccess.Helpers
|
||||
// It allows for multiple DataAccessManagers to be used however needed by the helper
|
||||
public class CreditorHelper
|
||||
{
|
||||
private static readonly DataAccessManager<Creditor> creditorDataAccess;
|
||||
private static readonly DataAccessManager<SettlementAttempt> settlementAttemptDataAccess;
|
||||
private readonly DataAccessManager<Creditor> creditorDataAccess;
|
||||
private readonly DataAccessManager<SettlementAttempt> settlementAttemptDataAccess;
|
||||
|
||||
static CreditorHelper()
|
||||
public CreditorHelper(DataAccessManager<Creditor> creditorDataAccess, DataAccessManager<SettlementAttempt> settlementAttemptDataAccess)
|
||||
{
|
||||
creditorDataAccess = Dependencies.Container.GetInstance<DataAccessManager<Creditor>>();
|
||||
settlementAttemptDataAccess = Dependencies.Container.GetInstance<DataAccessManager<SettlementAttempt>>();
|
||||
}
|
||||
|
||||
public CreditorHelper()
|
||||
{
|
||||
|
||||
this.creditorDataAccess = creditorDataAccess;
|
||||
this.settlementAttemptDataAccess = settlementAttemptDataAccess;
|
||||
}
|
||||
|
||||
public Creditor GetCreditor(int id)
|
||||
|
@ -8,7 +8,7 @@ namespace COA.EnterpriseServices.Sandbox
|
||||
{
|
||||
private static void Main(string[] args)
|
||||
{
|
||||
//ClientStuff();
|
||||
ClientStuff();
|
||||
CreditorStuff();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user