You should be able to generate an instance using reflection. Something
similar to this.
if (typeof(List<string>).IsGenericType)
{
Type t = typeof(List<string>).GetGenericTypeDefinition();
object obj = Activator.CreateInstance(t);
}
> Hi,
>
[quoted text clipped - 50 lines]
> Thanks,
> Florian
fstorck - 21 Aug 2006 13:01 GMT
Hello Jared,
just for clearification:
> if (typeof(List<string>).IsGenericType)
> {
> Type t = typeof(List<string>).GetGenericTypeDefinition();
Does the typeof accepts a string like "MyApp.MyGeneric`1[System.String]" or
<MyGenericOfInt32> for checking whether its generic and then create a type
definition from ? Or should I xml serialize the typedefinition when ( which
caused an exception using the XMLSerialize class)...
> You should be able to generate an instance using reflection. Something
> similar to this.
[quoted text clipped - 59 lines]
> > Thanks,
> > Florian
fstorck - 21 Aug 2006 13:32 GMT
Hi Jared,
I found a solution:
On deserialization, I do the following
Type t = Type.GetType(str_valtype);
object o = Activator.CreateInstance(t);
So this generates a Type description from a supplied type string.
Thanks for helping!
> You should be able to generate an instance using reflection. Something
> similar to this.
[quoted text clipped - 59 lines]
> > Thanks,
> > Florian