G
Guest
Imagine a class MasterStore carries a private hashtable. The hashtable will
carry 1 or more Dictionary<k,v>. MasterStore has a public method called
AddStore that adds new typed dictionaries to the master dict.
The dictionaries stored in the hashtable can all be of different types (i.e.
Dictionary<string,Customer> or Dictionary<string,Order>). What's important is
that all of the types in a specific Dictionary are all the same.
Can anyone point out a way to dynamically create a new Dictionary? The
method in AddStore will not compile.
I would not be surprised if this required runtime creation of code. That
would be acceptable for this issue.
public class MasterStore
{
private HashTable _storeMaster = new HashTable();
public void AddStore(System.Type t, string name)
{
_masterStore.Add(name, new DataStore<t>(name));
}
}
the goal is to make calls like
mStore.AddStore( typeof(Customer), 'customers')
mStore.AddStore( typeof(Order), 'orders' )
and have the appropriate Dictionary created for each line.
carry 1 or more Dictionary<k,v>. MasterStore has a public method called
AddStore that adds new typed dictionaries to the master dict.
The dictionaries stored in the hashtable can all be of different types (i.e.
Dictionary<string,Customer> or Dictionary<string,Order>). What's important is
that all of the types in a specific Dictionary are all the same.
Can anyone point out a way to dynamically create a new Dictionary? The
method in AddStore will not compile.
I would not be surprised if this required runtime creation of code. That
would be acceptable for this issue.
public class MasterStore
{
private HashTable _storeMaster = new HashTable();
public void AddStore(System.Type t, string name)
{
_masterStore.Add(name, new DataStore<t>(name));
}
}
the goal is to make calls like
mStore.AddStore( typeof(Customer), 'customers')
mStore.AddStore( typeof(Order), 'orders' )
and have the appropriate Dictionary created for each line.