T
tadmill
Is it possible for a class that accepts a generic type, to re-create
another instance of itself with a property type of the passed class?
ex.
public class SomeClass<T>
{
private PropertyInfo[] propInfos;
private Type objectType = typeof(T);
public SomeClass()
{
propInfos = objectType.GetProperties();
foreach (PropertyInfo pinn in propInfos)
{
if (pinn.PropertyType.IsGenericType &&
pinn.PropertyType.GetGenericTypeDefinition() == typeof(SomeClass<>))
{
//Can another SomeClass<> be created here with the property's
type?
}
}
}
}
I have attacked this 10 different ways and haven't come up with
anything that works. That may be because it can't be done; has anyone
else attempted this successfully?
TIA for any help,
Terry
another instance of itself with a property type of the passed class?
ex.
public class SomeClass<T>
{
private PropertyInfo[] propInfos;
private Type objectType = typeof(T);
public SomeClass()
{
propInfos = objectType.GetProperties();
foreach (PropertyInfo pinn in propInfos)
{
if (pinn.PropertyType.IsGenericType &&
pinn.PropertyType.GetGenericTypeDefinition() == typeof(SomeClass<>))
{
//Can another SomeClass<> be created here with the property's
type?
}
}
}
}
I have attacked this 10 different ways and haven't come up with
anything that works. That may be because it can't be done; has anyone
else attempted this successfully?
TIA for any help,
Terry