I am sorry if the title is misleading.
I have integer id's in such a way so that for particular pair of Id's, I have to execute a separate process in the application, while for other pair of ID's, other execution should be followed.
How can I put these id's in enum so that I can use Flags and on the basis of those flags, I can execute the process further.
e.g
For ID's (1000040, 1000049)---> ProcessBellBochumImport() For ID's (1000039,1000048) ---> ProcessAbrahamImport() For ID's (1000042,1000052) ---> ProcessTransthermoImport()
Moreover, I have idea to have Dictionary<int,IProcess> dictionary
so that,
as soon as I pass id, I should dynamically execute the corresponding process.
A possible implementation can be :
public enum ClientSubsidiaries
{
BellBochum : 000040 | 1000049,
Abraham : 1000039|1000048, don't know | or &
Transthermo : 1000042|1000052 | or & ..?
}
In other words, above stretegy is just the registration of a single process against couple of Id's.
class Import
{
Dictionary<int, IProcess> dictionary = new Dictionary<int, IProcess>();
public Import(int Id)
{
// something similar ......
(dictionary[Id]).ExecuteProcess();
}
}
I cahanged snum with the following, it seems this can be done somehow!!
[Flags]
public enum BellClientSubsidiaryGroup
{
BellBochum = 1000039 | 1000048,
Abraham = 1000040 | 1000049,
Transthermo = 1000042 | 1000050
}
I also initialize the dictionary
in the following way .
IDictionary<BellClientSubsidiaryGroup, IConsignmentBuilder<Bell>> BellCsIdToImportMap { get; set; }
public void initMap()
{
BellCsIdToImportMap[BellClientSubsidiaryGroup.BellBochum] = new BellBochumImport(importLookupData, forwarderId);
BellCsIdToImportMap[BellClientSubsidiaryGroup.Abraham] = new AbrahamImport(importLookupData, forwarderId);
BellCsIdToImportMap[BellClientSubsidiaryGroup.Transthermo] = new TransthermoImport(importLookupData, forwarderId);
}
public void Process(int ClientSubsidiaryId)
{
// here I need help... how can incoming id ( clientSubsidiaryId ) be mapped to Group of Ids
if ((ClientSubsidiaryId& BellClientSubsidiaryGroup.BellBochum) != 0)
{
}
}