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();
|
s.AssembliesFromApplicationBaseDirectory();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
c.For(typeof(IDataAccess<>)).Singleton();
|
||||||
|
c.For(typeof(DataAccessManager<>)).Singleton();
|
||||||
|
|
||||||
c.For<ClientHelper>().Singleton();
|
c.For<ClientHelper>().Singleton();
|
||||||
c.For<CreditorHelper>().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
|
// It allows for multiple DataAccessManagers to be used however needed by the helper
|
||||||
public class CreditorHelper
|
public class CreditorHelper
|
||||||
{
|
{
|
||||||
private static readonly DataAccessManager<Creditor> creditorDataAccess;
|
private readonly DataAccessManager<Creditor> creditorDataAccess;
|
||||||
private static readonly DataAccessManager<SettlementAttempt> settlementAttemptDataAccess;
|
private readonly DataAccessManager<SettlementAttempt> settlementAttemptDataAccess;
|
||||||
|
|
||||||
static CreditorHelper()
|
public CreditorHelper(DataAccessManager<Creditor> creditorDataAccess, DataAccessManager<SettlementAttempt> settlementAttemptDataAccess)
|
||||||
{
|
{
|
||||||
creditorDataAccess = Dependencies.Container.GetInstance<DataAccessManager<Creditor>>();
|
this.creditorDataAccess = creditorDataAccess;
|
||||||
settlementAttemptDataAccess = Dependencies.Container.GetInstance<DataAccessManager<SettlementAttempt>>();
|
this.settlementAttemptDataAccess = settlementAttemptDataAccess;
|
||||||
}
|
|
||||||
|
|
||||||
public CreditorHelper()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Creditor GetCreditor(int id)
|
public Creditor GetCreditor(int id)
|
||||||
|
@ -8,7 +8,7 @@ namespace COA.EnterpriseServices.Sandbox
|
|||||||
{
|
{
|
||||||
private static void Main(string[] args)
|
private static void Main(string[] args)
|
||||||
{
|
{
|
||||||
//ClientStuff();
|
ClientStuff();
|
||||||
CreditorStuff();
|
CreditorStuff();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user