R
RSH
Hi,
I have a situation where I have multiple objects created from concrete
classes:
// Concrete implementations of the Abstract class ApprovalChain
MarketingApprovalChain MktgAppChain = new MarketingApprovalChain();
AccountingApprovalChain AcctAppChain = new AccountingApprovalChain();
I also have a Department enum
public enum Department
{
Acct,Mktg
}
Armed with that information I need to pass those objects to another class
dynamically. (Im trying to avoid hardcoding the logic is a case conditional:
public class Purchase
{
public Purchase(ApprovalChain appChain)
{
...
}
}
back to the original method:
private MarketingApprovalChain MktgAppChain = new MarketingApprovalChain();
private AccountingApprovalChain AcctAppChain = new
AccountingApprovalChain();
public void PurchaseRequisition(Department dept)
{
Purchase purchase = new Purchase();<----- is there a way here to use the
string value of the enum to dynamically make reference to the appropriate
ApprovalChain to pass to the Purchase Class Constructor?
}
PsuedoCode: Purchase purchase = new Purchase(dept.ToString() +
"ApprovalChain");
Thanks alot!
Ron
I have a situation where I have multiple objects created from concrete
classes:
// Concrete implementations of the Abstract class ApprovalChain
MarketingApprovalChain MktgAppChain = new MarketingApprovalChain();
AccountingApprovalChain AcctAppChain = new AccountingApprovalChain();
I also have a Department enum
public enum Department
{
Acct,Mktg
}
Armed with that information I need to pass those objects to another class
dynamically. (Im trying to avoid hardcoding the logic is a case conditional:
public class Purchase
{
public Purchase(ApprovalChain appChain)
{
...
}
}
back to the original method:
private MarketingApprovalChain MktgAppChain = new MarketingApprovalChain();
private AccountingApprovalChain AcctAppChain = new
AccountingApprovalChain();
public void PurchaseRequisition(Department dept)
{
Purchase purchase = new Purchase();<----- is there a way here to use the
string value of the enum to dynamically make reference to the appropriate
ApprovalChain to pass to the Purchase Class Constructor?
}
PsuedoCode: Purchase purchase = new Purchase(dept.ToString() +
"ApprovalChain");
Thanks alot!
Ron