I'm not sure how to correct this. I have
public void get_json(String TYPE)
{
Type t = Type.GetType("campusMap." + TYPE);
t[] all_tag = ActiveRecordBase<t>.FindAll();
}
But I always just get
Error 9 The type or namespace name 't' could not be found (are you missing a using directive or an assembly reference?) C:_SVN_\campusMap\campusMap\Controllers\publicController.cs 109 17 campusMap
any ideas on why if I'm defining the type I am wishing to gain access to is saying it's not working? I have tried using reflection to do this with no luck. Anyone able to provide a solution example?
[EDIT] possible solution
This is trying to use the reflection and so I'd pass the string and invoke the mothod with the generic.
public void get_json(String TYPE)
{
CancelView();
CancelLayout();
Type t = Type.GetType(TYPE);
MethodInfo method = t.GetMethod("get_json_data");
MethodInfo generic = method.MakeGenericMethod(t);
generic.Invoke(this, null);
}
public void get_json_data<t>()
{
t[] all_tag = ActiveRecordBase<t>.FindAll();
List<JsonAutoComplete> tag_list = new List<JsonAutoComplete>();
foreach (t tag in all_tag)
{
JsonAutoComplete obj = new JsonAutoComplete();
obj.id = tag.id;
obj.label = tag.name;
obj.value = tag.name;
tag_list.Add(obj);
}
RenderText(JsonConvert.SerializeObject(tag_list));
}
and the error I get is in..
obj.id = tag.id;
of 't' does not contain a definition for 'id'
and same for the two name ones.