I have code similar to this:
class Foo {
Dictionary<Type, Object> _dict;
void Create(string myType, string myValue)
{
var instance = Type.Instanciate(myType) // How do I do this?
if (var.IsPrimitive)
{
var.GetType().Parse(myValue) // I know this is there...how to invoke?
Dictionary[instance.GetType()] = instance;
}
}
T GetValue<T>(T myType) { return (T)_dict[T]; }
}
// Populate with values
foo.Create("System.Int32", "15");
foo.Create("System.String", "My String");
foo.Create("System.Boolean", "False");
// Access a value
bool b = GetValue(b);
So my questions are:
a) How do I instantiate the type
b) Parse the type value from a string when Parse is supported.